MCPcopy
hub / github.com/binux/qiandao / angularInit

Function angularInit

web/static/components/angularjs/angular.js:1323–1365  ·  view source on GitHub ↗

* @ngdoc directive * @name ngApp * @module ng * * @element ANY * @param {angular.Module} ngApp an optional application * angular.module module name to load. * * @description * * Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive * designates

(element, bootstrap)

Source from the content-addressed store, hash-verified

1321 *
1322 */
1323function angularInit(element, bootstrap) {
1324 var elements = [element],
1325 appElement,
1326 module,
1327 names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],
1328 NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/;
1329
1330 function append(element) {
1331 element && elements.push(element);
1332 }
1333
1334 forEach(names, function(name) {
1335 names[name] = true;
1336 append(document.getElementById(name));
1337 name = name.replace(':', '\\:');
1338 if (element.querySelectorAll) {
1339 forEach(element.querySelectorAll('.' + name), append);
1340 forEach(element.querySelectorAll('.' + name + '\\:'), append);
1341 forEach(element.querySelectorAll('[' + name + ']'), append);
1342 }
1343 });
1344
1345 forEach(elements, function(element) {
1346 if (!appElement) {
1347 var className = ' ' + element.className + ' ';
1348 var match = NG_APP_CLASS_REGEXP.exec(className);
1349 if (match) {
1350 appElement = element;
1351 module = (match[2] || '').replace(/\s+/g, ',');
1352 } else {
1353 forEach(element.attributes, function(attr) {
1354 if (!appElement && names[attr.name]) {
1355 appElement = element;
1356 module = attr.value;
1357 }
1358 });
1359 }
1360 }
1361 });
1362 if (appElement) {
1363 bootstrap(appElement, module ? [module] : []);
1364 }
1365}
1366
1367/**
1368 * @ngdoc function

Callers 1

angular.jsFile · 0.85

Calls 3

forEachFunction · 0.85
appendFunction · 0.85
bootstrapFunction · 0.85

Tested by

no test coverage detected