当前位置: 动力学知识库 > 问答 > 编程问答 >

angularjs - Upgrading Angular version

问题描述:

I have a web application using angular v1.1.5 and i am trying to update this to v.1.2.9.

I have downloaded v1.2.9 and the corresponding route.js file however when trying to run my application, i am seeing the below:

Error: [$injector:modulerr] http://errors.angularjs.org/1.2.9/$injector/modulerr?p0=app&p1=%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.2.9%2F%24injector%2Fmodulerr%3Fp0%3DngRoute%26p1

main.js:

(function(require) {

'use strict';

require.config({

baseUrl: '/resources/js',

paths: {

'zepto' : 'vendor/zepto',

'jquery' : 'vendor/jquery',

'angular' : 'vendor/angular',

'ngRoute' : 'vendor/route',

// 'ngResource': 'vendor/resource',

'router' : 'vendor/page',

'history' : 'vendor/history.iegte8',

'event' : 'vendor/eventemitter2'

},

shim: {

'zepto' : { exports: '$' },

'angular' : { deps: ['jquery'], exports: 'angular' },

'ngRoute' : { deps: ['angular'], exports: 'angular' },

// 'ngResource': { deps: ['angular'], exports: 'angular' },

'app' : { deps: ['angular'] },

'router' : { exports: 'page'}

}

});

require(['angular', 'app'], function (angular, app) {

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

});

})(this.require);

app.js:

define("app", ["angular"], function(angular){

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

app.config(function($routeProvider, $locationProvider){

$routeProvider

.when("/home", {

templateUrl: "home.html",

controller: "HomeController"

})

.when("/products", {

templateUrl: "products.html",

controller: "ProductsController"

})

.otherwise({ redirectTo: '/products'});

});

return app;

});

Any advice appreciated.

Update**********************************************

If i change (app.js):

define("app", ["angular"], function(angular){

to:

define("app", ["angular", "ngRoute"], function(angular){

I get the following error:

TypeError: e is undefined

...controller,f),b.controllerAs&&(a[b.controllerAs]=f),c.data("$ngControllerControl...

网友答案:

I'm not familiar with require.js, but wouldn't you need to inject it here as well?

require(['angular', 'ngRoute', 'app'], function (angular, app, ngRoute) {
    angular.bootstrap(document,['app', 'ngRoute']);
});

I might be out on deep waters here though.

分享给朋友:
您可能感兴趣的文章:
随机阅读: