如何使用ng-polymer-elements,angularjs和requirejs?

前端之家收集整理的这篇文章主要介绍了如何使用ng-polymer-elements,angularjs和requirejs?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用具有角度和要求的ng-polymer-elements.我确实遵循了 https://github.com/GabiAxel/ng-polymer-elements的说明,但我没有成功.当我在“main.js”中从我的要求中删除实例“ng-polymer-elements”时,一切正常.有人可以帮帮我吗?谢谢.

一个小问题部分:

未捕获的错误:[$injector:modulerr]由于以下原因无法实例化模块Coderup:
错误:[$injector:nomod]模块’Coderup’不可用!您要么错误拼写了模块名称,要么忘记加载它.如果注册模块,请确保将依赖项指定为第二个参数.

main.js

require.config({
        paths: {
             angular: '../bower_components/angular/angular','angular-animate': '../bower_components/angular-animate/angular-animate','angular-cookies': '../bower_components/angular-cookies/angular-cookies','angular-mocks': '../bower_components/angular-mocks/angular-mocks','angular-resource': '../bower_components/angular-resource/angular-resource','angular-sanitize': '../bower_components/angular-sanitize/angular-sanitize','angular-scenario': '../bower_components/angular-scenario/angular-scenario','angular-touch': '../bower_components/angular-touch/angular-touch',bootstrap: '../bower_components/bootstrap/dist/js/bootstrap','ng-polymer-elements' : '../bower_components/ng-polymer-elements/ng-polymer-elements.min',platform : '../bower_components/platform/platform','uiRouter' : '../bower_components/angular-ui-router/release/angular-ui-router',jquery : '../bower_components/jquery/dist/jquery.min'
        },shim: {
            angular: {
                deps: ['platform'],exports: 'angular'
            },platform : {
                exports : 'platform'
            },jquery : {
                exports: 'jquery'
            },'ng-polymer-elements' : [
                'angular'
            ],'uiRouter': [
                'angular'
            ],'angular-cookies': [
                'angular'
            ],'angular-sanitize': [
                'angular'
            ],'angular-resource': [
                'angular'
            ],'angular-animate': [
                'angular'
            ],'angular-touch': [
                'angular'
            ],'angular-mocks': {
                deps: [
                    'angular'
                ],exports: 'angular.mock'
            }
        },priority: [
            'angular'
        ],packages: [

        ]
    });

    window.name = 'NG_DEFER_BOOTSTRAP!';

    require([
        'angular','app','uiRouter','ng-polymer-elements','controllers/config','directives/config'
    ],function(angular,app) {
        'use strict';

        /* jshint ignore:start */
        var $html = angular.element(document.getElementsByTagName('html')[0]);
        /* jshint ignore:end */

        angular.element().ready(function() {
            angular.bootstrap(document,[app.name]);
        });
    });

app.js

define(['angular','ng-polymer-elements'],function (angular) {
        'use strict';

        var app = angular.module('Coderup',['ui.router','appControllers','appDirectives'])
            .config(function ($stateProvider,$urlRouterProvider) {

                var dirView = "../views/";
                $urlRouterProvider.otherwise("/learn");

                $stateProvider
                    .state('learn',{
                        url: "",controller: 'DadController'
                    })
                    .state('route1',{
                        url: "/route1",views: {
                            "container": {
                                templateUrl: dirView + "teste.html"
                            }
                        }
                    });
            });
        return app
    });

问题:

Uncaught Error: [$injector:modulerr] Failed to instantiate module Coderup due to:
Error: [$injector:nomod] Module 'Coderup' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.3.0/$injector/nomod?p0=Coderup
    at http://localhost:9000/bower_components/angular/angular.js:80:12
    at http://localhost:9000/bower_components/angular/angular.js:1797:17
    at ensure (http://localhost:9000/bower_components/angular/angular.js:1721:38)
    at module (http://localhost:9000/bower_components/angular/angular.js:1795:14)
    at http://localhost:9000/bower_components/angular/angular.js:4064:22
    at forEach (http://localhost:9000/bower_components/angular/angular.js:335:20)
    at loadModules (http://localhost:9000/bower_components/angular/angular.js:4048:5)
    at createInjector (http://localhost:9000/bower_components/angular/angular.js:3974:11)
    at doBootstrap (http://localhost:9000/bower_components/angular/angular.js:1484:20)
    at Object.bootstrap (http://localhost:9000/bower_components/angular/angular.js:1505:12)
http://errors.angularjs.org/1.3.0/$injector/modulerr?p0=Coderup&p1=Error%3A…F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A1505%3A12)

Guys please,help me to resolve it. You can get this project by git.

git clone https://vcrzy@bitbucket.org/vcrzy/coderup.git
 npm install
 run mongod
 cd /app
 node app.js
 go http://localhost:9000
您可能遇到文件加载顺序的问题.您需要使用所有依赖项来填充您的应用程序,沿着这些行添加一些内容到shim部分:
app: [
  'angular',...
  // list all other deps
]

解决此问题的最佳方法是观察“网络”选项卡,查看文件加载方式,并确保按正确顺序加载.

原文链接:https://www.f2er.com/angularjs/142053.html

猜你在找的Angularjs相关文章