推断式注入:
function controllerName($scope){
$scope.msg="hello world";
}
显示注入:
var mapp=angular.module("myapp",[]);
var controllerName=function (a){
a.msg="hello world"
}
controllerName.$inject=["$scope"];
myapp.controller("controllerName",controllerName)
行内注入:
var myapp=angular.module("myapp",[]);
myapp.controller("controllerName",["$scope",function($scope){
$scope.msg="hello world";(把$scope注入到function的参数中)
}