MCPcopy
hub / github.com/angular-ui/ui-router / angularInit

Function angularInit

test/angular/1.2/angular.js:1330–1372  ·  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

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

Callers 1

angular.jsFile · 0.70

Calls 3

appendFunction · 0.85
forEachFunction · 0.70
bootstrapFunction · 0.70

Tested by

no test coverage detected