angular.module什么意思 angular httpclientmodule和httpmodule的区别
angular.module什么意思
模块可以说是AngularJS 的根本。它包含配置、控制、过滤、工厂模式、指令及其它模块。
如果你熟悉.NET平台,但初步学习Angular。下面的表格是一个简要的对比,帮助你理解Angular中的角色扮演情况:
例如,下面的代码使用控制器、过滤器和指令创建了一个模块:
// the main (app) module
var myApp = angular.module("myApp", [])
// add a controller
myApp.controller("myCtrl", function($scope) {
$scope.msg = "grapecity team blog"
})
// add a filter
myApp.filter("myUpperFilter", function() {
return function(input) {
return input.toUpperCase()
}
})
// add a directive
myApp.directive("myDctv", function() {
return function(scope, element, attrs) {
element.bind("mouseenter", function() {
element.css("background", "yellow")
})
element.bind("mouseleave", function() {
element.css("background", "none")
})
}
})
上面示例中module 方法的第一个参数为模块的名称,第二个参数为它的依赖模块列表。我们创建了一个独立的模块,不依赖于其它模块。所以第二个参数为空数组(注意:即使它为空,我们也必须填写这个参数。否则,该方法回去检索之前的同名模块)。
angular httpclientmodule和httpmodule的区别
没有区别,只是写法不一样而已,第一种可以拿到app变量,方便在在其他文件中定义controllerdirective等。第二种可以直接在后面继续写.controller()…………。本质没有区别