我无法让我的应用程序的角度侧启动和运行,我在浏览器控制台得到这3个错误:
Uncaught TypeError: Cannot read property '$$minErr' of undefined .js:8
Uncaught TypeError: Cannot read property 'module' of undefined
Uncaught ReferenceError: angular is not defined
如果我在浏览器开发工具中点击我的脚本,它们都正确链接,并且在我的服务器控制台上得到代码200,但它似乎不像angular脚本让我创建一个angular对象。
//Here is my angular app page code:
angular.module('app', ['ngResource', 'ngRoute']);
angular.module('app').config(function($routeProvider, $locationProvider){
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {templateUrl: '/partials/main', controller: 'mainCtrl'});
});
angular.module('app').controller('mainCtrl', function($scope){
$scope.myVar = "Hello Angular";
});
//Here is my layout.jade page:
doctype
html
head
//link(href="/favicon.icon", rel="shortcut icon", type="image/x-icon")
link(rel="stylesheet" href="/css/bootstrap.css")
link(rel="stylesheet" href="/vender/toastr/toastr.css")
link(rel="stylesheet" href="/css/site.css")
body(ng-app='app')
block main-content
include scripts
//Here is my included scripts.jade page:
script(type="text/javascript", src="/vender/jquery/jquery.js")
script(type="text/javasctipt", src="/vender/angular.min.js")
script(type="text/javascript", src="/vender/angular-resource/angular-resource.js")
script(type="text/javascript", src="/vender/angular-route/angular-route.js")
script(type="text/javascript", src="/app/app.js")
如果你想看我代码的其他部分,这里是一个存储库链接:https://github.com/dakhipp/meanTutorial
或者告诉我,我可以粘贴任何你需要看到的东西。谢谢你的帮助!!
要修复它,请尝试以下操作:
var app = angular.module('app', ['ngRoute']);
app.config(function($routeProvider, $locationProvider){
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {templateUrl: '/partials/main', controller: 'mainCtrl'});
});
app.controller('mainCtrl', ['$scope', function($scope){
$scope.myVar = "Hello Angular";
}]);
我不确定你想用ngResource做什么,但这里有一个工作示例。http://plnkr.co/edit/DdtPhcLKDla6958YNuwc?p=preview