AngularJs将工厂注入控制器
问题描述:
亲爱的,
我正在尝试执行以下操作:
Dears ,
I'm trying to do the following :
var common = angular.module('common', ['ui.bootstrap']);
var app = angular.module('app', ['common']);
(function (cr) {
var modelHelper = function () {
var self = this;
self.getObjectById = function (object, key, value) {
angular.forEach(object, function (objKey, objValue) {
var a = 0;
});
return undefined;
};
};
cr.modelHelper = modelHelper;
}(window.sys));
dgitCommon.factory('modelHelper', function () {
return sys.modelHelper();
});
并没有将'modelHelper'注入到控制器中,如下所示:
and its not injecting the 'modelHelper' into the controller like bellow :
app.controller("xController", function ($scope, $modal, modelHelper) {
});
提前致谢。
Thanks in advance .
答
范围,
modal,modelHelper){
});
modal, modelHelper) { });
提前致谢。
Thanks in advance .
(function (cr) {
var modelHelper = function () {
var self = this;
self.getObjectById = function (object, key, value) {
angular.forEach(object, function (objKey, objValue) {
var a = 0;
});
return undefined;
};
return this ;/// this what i forget to code
};
cr.modelHelper = modelHelper;
}(window.sys));