代码之家  ›  专栏  ›  技术社区  ›  sol

角度1.6.5角度。引导注入错误

  •  -1
  • sol  · 技术社区  · 9 年前

    我有一个想法。org skeleton应用程序,我已经将其转换为hapi js而不是express,也将其转换为postgres而不是mongo,并使用OAUTH进行身份验证。(好的,真的,我只是喜欢服务器/客户端模块的文件夹结构-lol)

    angular.bootstrap(document, [app.applicationModuleName]);

    如果我对此进行评论并添加 ng-app="appName"

    我已经确认其他一切都在加载,没有错误…不知道从这里去哪里…有什么建议吗?

    @matias要求完整代码,这是角度配置:

    (function (window) {
      'use strict';
    
      var applicationModuleName = 'appName';
    
      var service = {
        applicationEnvironment: window.env,
        applicationModuleName: applicationModuleName,
        applicationModuleVendorDependencies: ['ngResource', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap','ui-notification'],
        registerModule: registerModule
      };
    
      window.ApplicationConfiguration = service;
    
      // Add a new vertical module
      function registerModule(moduleName, dependencies) {
        // Create angular module
        angular.module(moduleName, dependencies || []);
    
        // Add the module to the AngularJS configuration file
        angular.module(applicationModuleName).requires.push(moduleName);
      }
    
      // Angular-ui-notification configuration
      angular.module('ui-notification').config(function(NotificationProvider) {
        NotificationProvider.setOptions({
          delay: 2000,
          startTop: 20,
          startRight: 10,
          verticalSpacing: 20,
          horizontalSpacing: 20,
          positionX: 'right',
          positionY: 'bottom'
        });
      });
    }(window));
    

    这是角度初始化(先加载配置,然后加载初始化):

    (function (app) {
      'use strict';
    
      // Start by defining the main module and adding the module dependencies
      angular
        .module(app.applicationModuleName, app.applicationModuleVendorDependencies);
    
      // Setting HTML5 Location Mode
      angular
        .module(app.applicationModuleName)
        .config(bootstrapConfig);
    
      bootstrapConfig.$inject = ['$compileProvider', '$locationProvider', '$httpProvider', '$logProvider'];
    
      function bootstrapConfig($compileProvider, $locationProvider, $httpProvider, $logProvider) {
        $locationProvider.html5Mode({
          enabled: true,
          requireBase: false
        }).hashPrefix('!');
    
        $httpProvider.interceptors.push('authInterceptor');
    
        // Disable debug data for production environment
        // @link https://docs.angularjs.org/guide/production
        $compileProvider.debugInfoEnabled(app.applicationEnvironment !== 'production');
        $logProvider.debugEnabled(app.applicationEnvironment !== 'production');
      }
    
    
      // Then define the init function for starting up the application
      angular.element(document).ready(init);
    
      function init() {
        // Fixing facebook bug with redirect
        if (window.location.hash && window.location.hash === '#_=_') {
          if (window.history && history.pushState) {
            window.history.pushState('', document.title, window.location.pathname);
          } else {
            // Prevent scrolling by storing the page's current scroll offset
            var scroll = {
              top: document.body.scrollTop,
              left: document.body.scrollLeft
            };
            window.location.hash = '';
            // Restore the scroll offset, should be flicker free
            document.body.scrollTop = scroll.top;
            document.body.scrollLeft = scroll.left;
          }
        }
    
        // Then init the app
        angular.bootstrap(document, [app.applicationModuleName]);
      }
    }(ApplicationConfiguration));
    
    2 回复  |  直到 8 年前
        1
  •  1
  •   Mati    9 年前

    试试这个,首先你必须创建你的应用程序(名称+依赖项列表):

    var app = angular.module('myApp', []);
    

    angular.bootstrap(document, [app.name]);
    
        2
  •  0
  •   sol    9 年前

    好我感到羞怯。我尝试了一种更简单的方法,并介入我正在做的事情,看看是否能找到罪魁祸首。

    结果是,我的ui注入。bootstrap是失败的项目(谢谢@estus-你的评论让我对其他模块进行了更深入的挖掘)。它之所以失败,是因为我是个跛子,胖手指着资产管道中的路径,所以该库在页面上不存在。

    *羞愧地垂下头*

    谢谢大家的快速帮助。非常感谢。

    推荐文章