是module的方法
factory(name, providerFunction);
存儲方法
<body ng-app='myapp' ng-controller='mytest'>
<input ng-model='test'>{{test}}
<br>{{output}}</body>
var app = angular.module('myapp', []).value('testvalue', 'widuu').factory('testfactory',
function(testvalue) {
return {
lable: function() {
return "this can output : hello " + testvalue;
}
}
});
app.controller('mytest',
function($scope, testvalue, testfactory) {
$scope.test = "hello " + testvalue;
$scope.output = testfactory.lable();
});
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者