angularjs1.x中模块关系

最近开发中,发现angularjs模块之间存在这样这样一种关系

// 子模块
angular.module('app.child',[])
.factory('fc',['g',function(g){
    console.log(g)
    // 输出为 {v:1}
}])
// 主模块
angular.module('app',['app.child'])
.constant('g', {v:1})

这种子模块的命名方式,可以正确打印出g的值,

如果将子模块命名为child

angular.module('child')

那么在运行的时候会报g注入错误。

猜你喜欢

转载自blog.csdn.net/peade/article/details/89056530