MCPcopy Index your code
hub / github.com/apache/cloudstack / angularInit

Function angularInit

tools/ngui/static/js/lib/angular.js:914–956  ·  view source on GitHub ↗

* @ngdoc directive * @name ng.directive:ngApp * * @element ANY * @param {angular.Module} ngApp an optional application * angular.module module name to load. * * @description * * Use this directive to auto-bootstrap an application. Only * one directive can be used per HTML documen

(element, bootstrap)

Source from the content-addressed store, hash-verified

912 *
913 */
914function angularInit(element, bootstrap) {
915 var elements = [element],
916 appElement,
917 module,
918 names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],
919 NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/;
920
921 function append(element) {
922 element && elements.push(element);
923 }
924
925 forEach(names, function(name) {
926 names[name] = true;
927 append(document.getElementById(name));
928 name = name.replace(':', '\\:');
929 if (element.querySelectorAll) {
930 forEach(element.querySelectorAll('.' + name), append);
931 forEach(element.querySelectorAll('.' + name + '\\:'), append);
932 forEach(element.querySelectorAll('[' + name + ']'), append);
933 }
934 });
935
936 forEach(elements, function(element) {
937 if (!appElement) {
938 var className = ' ' + element.className + ' ';
939 var match = NG_APP_CLASS_REGEXP.exec(className);
940 if (match) {
941 appElement = element;
942 module = (match[2] || '').replace(/\s+/g, ',');
943 } else {
944 forEach(element.attributes, function(attr) {
945 if (!appElement && names[attr.name]) {
946 appElement = element;
947 module = attr.value;
948 }
949 });
950 }
951 }
952 });
953 if (appElement) {
954 bootstrap(appElement, module ? [module] : []);
955 }
956}
957
958/**
959 * @ngdoc function

Callers 1

angular.jsFile · 0.85

Calls 4

forEachFunction · 0.85
appendFunction · 0.85
bootstrapFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected