和 勇哥的 DpMngWebsite
------------ * 错误排除 * ------------
C#:
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/AngularJs").Include(
"~/Scripts/angular.js", "~/Scripts/angular*"));
Aspx:
<html lang="en" ng-app="enron">
<head runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%: Page.Title %></title>
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/AngularJs") %>
<%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder>
错误:VS蹦出错误:“无效的字符” 并且显示Angular-csp.css
解决:学习了http://stackoverflow.com/questions/26916671/angular-csp-css-breaking-in-chrome-extension之后,将angular-csp.css移出了Scripts的文件夹,并放入了Content文件夹。有错误是因为CSS文件被VS当成js读了。
------------------------------------
JS:
angular.module('enron').controller('NameListController', ['$rootScope', '$scope', '$routeParams', '$http', function ($rootScope, $scope, $routeParams, $http) {
$scope.sayhello = function () {
alert('hello'); return;
}
}]);
错误:
Angularjs module isn't loading correctly
解决:在 'enron' 后面加 ', [ ] '
angular.module('enron',[]).controller('NameListController', ['$rootScope', '$scope', '$http', function ($rootScope, $scope, $http) {
$scope.sayhello = function () {
alert('hello'); return;
}
}]);
------------------------------------
JS:
angular.module('enron',[]).controller('NameListController', ['$rootScope', '$scope', '$routeParams', '$http', function ($rootScope, $scope, $routeParams, $http) {
$scope.sayhello = function () {
alert('hello'); return;
}
}]);
错误:
Error: [$injector:unpr] Unknown provider: routeParamsProvider <- routeParams
解决:直接删除 routeParams
angular.module('enron',[]).controller('NameListController', ['$rootScope', '$scope', '$http', function ($rootScope, $scope, $http) {
$scope.sayhello = function () {
alert('hello'); return;
}
}]);