我正在审查以下内容:
(function () {
'use strict';
window.angular
.module('moduleName')
.directive('DirectiveName', function () {
return {
restrict: 'AE',
templateUrl: '/app/moduleName/list/template.html',
controller: 'someController',
controllerAs: 'someCtrl',
}
});
}());
我一直在用
angular
.module('myModule')
//etc
而不是从 window.angular
开始。
因为我假设 angular 的作用域是针对窗口的,所以这两种语法之间有什么真正的、实际的区别吗?
最佳答案
完全没有。在浏览器窗口中是全局对象,
如这里所写 - https://developer.mozilla.org/en-US/docs/Web/API/Window/window :
In web pages, the window object is also a global object. This means that:
global variables of your script are in fact properties of window:
var global = {data: 0}; alert(global === window.global); // displays "true"
you can access built-in properties of the window object without having to type window. prefix:
setTimeout("alert('Hi!')", 50); // equivalent to using window.setTimeout. alert(window === window.window); // displays "true"
关于javascript - angular.module 和 window.angular.module 之间有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32113784/