摘要:自訂factory內的方法
//下面這三種寫法是相同的
myModule.controller('MyController' ,
function($scope,greeter){
$scope.sayHello = function() {
greeter.greet($scope.msg);
};
}
);
myModule.controller('MyController' ,
['$scope','greeter',
function($scope,greeter){
$scope.sayHello = function() {
greeter.greet($scope.msg);
};
}
]);
function MyController($scope, greeter) {
$scope.sayHello = function() {
greeter.greet($scope.msg);
};
}