MCPcopy Create free account
hub / github.com/bclinkinbeard/angular / angularInit

Function angularInit

test/fixtures/foo.js:1328–1370  ·  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

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

Callers 1

foo.jsFile · 0.85

Calls 3

forEachFunction · 0.85
appendFunction · 0.85
bootstrapFunction · 0.85

Tested by

no test coverage detected