angular.js最核心的几句
它们是放在框架的最后几句,由于自带太多指令了。因此可允许用户一行JS也不用就能构建一个智能的应用。
bindJQuery(); publishExternalAPI(angular); jqLite(document).ready( function () { angularInit(document, bootstrap); }); |
决定是使用jQuery还是自带的jqLite,如果是jQuery还要加工一下。
function bindJQuery() { // bind to jQuery if present; jQuery = window.jQuery; // reset to jQuery or default to us. if (jQuery) { jqLite = jQuery; extend(jQuery.fn, { scope: JQLitePrototype.scope, controller: JQLitePrototype.controller, injector: JQLitePrototype.injector, inheritedData: JQLitePrototype.inheritedData }); JQLitePatchJQueryRemove( 'remove' , true ); JQLitePatchJQueryRemove( 'empty' ); JQLitePatchJQueryRemove( 'html' ); } else { jqLite = JQLite; } angular.element = jqLite; } |
function publishExternalAPI(angular){ extend(angular, { 'bootstrap' : bootstrap, //这些都是Angular.js这件的内部方法,需要将它们放到angular中去 'copy' : copy, 'extend' : extend, 'equals' : equals, 'element' : jqLite, 'forEach' : forEach, 'injector' : createInjector, 'noop' :noop, 'bind' :bind, 'toJson' : toJson, 'fromJson' : fromJson, 'identity' :identity, 'isUndefined' : isUndefined, 'isDefined' : isDefined, 'isString' : isString, 'isFunction' : isFunction, 'isObject' : isObject, 'isNumber' : isNumber, 'isElement' : isElement, 'isArray' : isArray, 'version' : version, 'isDate' : isDate, 'lowercase' : lowercase, 'uppercase' : uppercase, 'callbacks' : {counter: 0} }); angularModule = setupModuleLoader(window); try { angularModule( 'ngLocale' ); } catch (e) { angularModule( 'ngLocale' , []).provider( '$locale' , $LocaleProvider); } angularModule( 'ng' , [ 'ngLocale' ], [ '$provide' , function ngModule($provide) { $provide.provider( '$compile' , $CompileProvider). directive({ ///ng/directive/这个文件下的所有JS文件,一个指令一个JS文件。里面告诉编译器如何抽取它们与绑定事件。 a: htmlAnchorDirective, input: inputDirective, textarea: inputDirective, form: formDirective, script: scriptDirective, select: selectDirective, style: styleDirective, option: optionDirective, ngBind: ngBindDirective, ngBindHtmlUnsafe: ngBindHtmlUnsafeDirective, ngBindTemplate: ngBindTemplateDirective, ngClass: ngClassDirective, ngClassEven: ngClassEvenDirective, ngClassOdd: ngClassOddDirective, ngCsp: ngCspDirective, ngCloak: ngCloakDirective, ngController: ngControllerDirective, ngForm: ngFormDirective, ngHide: ngHideDirective, ngInclude: ngIncludeDirective, ngInit: ngInitDirective, ngNonBindable: ngNonBindableDirective, ngPluralize: ngPluralizeDirective, ngRepeat: ngRepeatDirective, ngShow: ngShowDirective, ngSubmit: ngSubmitDirective, ngStyle: ngStyleDirective, ngSwitch: ngSwitchDirective, ngSwitchWhen: ngSwitchWhenDirective, ngSwitchDefault: ngSwitchDefaultDirective, ngOptions: ngOptionsDirective, ngView: ngViewDirective, ngTransclude: ngTranscludeDirective, ngModel: ngModelDirective, ngList: ngListDirective, ngChange: ngChangeDirective, required: requiredDirective, ngRequired: requiredDirective, ngValue: ngValueDirective }). directive(ngAttributeAliasDirectives). directive(ngEventDirectives); $provide.provider({ //这是直接放在ng目标下的文件,用于提供不同的功能与重要对象 $anchorScroll: $AnchorScrollProvider, $browser: $BrowserProvider, $cacheFactory: $CacheFactoryProvider, $controller: $ControllerProvider, $document: $DocumentProvider, $exceptionHandler: $ExceptionHandlerProvider, $filter: $FilterProvider, $interpolate: $InterpolateProvider, $http: $HttpProvider, $httpBackend: $HttpBackendProvider, $location: $LocationProvider, $log: $LogProvider, $parse: $ParseProvider, $route: $RouteProvider, $routeParams: $RouteParamsProvider, $rootScope: $RootScopeProvider, $q: $QProvider, $sniffer: $SnifferProvider, $templateCache: $TemplateCacheProvider, $timeout: $TimeoutProvider, $window: $WindowProvider }); } ]); } |
function bootstrap(element, modules) { //开始构娅应用 var resumeBootstrapInternal = function () { element = jqLite(element); modules = modules || []; modules.unshift([ '$provide' , function ($provide) { $provide.value( '$rootElement' , element); }]); modules.unshift( 'ng' ); var injector = createInjector(modules); injector.invoke([ '$rootScope' , '$rootElement' , '$compile' , '$injector' , function (scope, element, compile, injector) { scope.$apply( function () { element.data( '$injector' , injector); compile(element)(scope); }); }] ); return injector; }; var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { return resumeBootstrapInternal(); } window.name = window.name.replace(NG_DEFER_BOOTSTRAP, '' ); angular.resumeBootstrap = function (extraModules) { forEach(extraModules, function (module) { modules.push(module); }); resumeBootstrapInternal(); }; } |
如果您觉得此文有帮助,可以打赏点钱给我支付宝1669866773@qq.com ,或扫描二维码


机器瞎学/数据掩埋/模式混淆/人工智障/深度遗忘/神经掉线/计算机幻觉/专注单身二十五年
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
2012-04-12 修改浏览器 User-Agent
2011-04-12 我的模块加载系统 v5