Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何使用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’不可用!您要么错误拼写了模块名称,要么忘记加载它.如果注册模块,请确保将依赖项指定为第二个参数.

@H_126_1@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:@L_874_13@8: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)
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
]

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

大佬总结

以上是大佬教程为你收集整理的如何使用ng-polymer-elements,angularjs和requirejs?全部内容,希望文章能够帮你解决如何使用ng-polymer-elements,angularjs和requirejs?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。