我是angularJS的新手.我试着练习一些例子并遇到了一个非常棘手的错误.我花了几个小时来弄清楚RangeError,但我没能克服它.任何人都可以帮我摆脱这个陷阱吗?
在app.js
var sampleApp = angular.module('phonecatApp',['ngRoute']); sampleApp .config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) { $routeProvider. when('/',{ templateUrl: 'index.html',}). when('/addOrder',{ templateUrl: 'add-order.html',controller: 'AddOrderController' }). when('/showOrders',{ templateUrl: 'show-orders.html',controller: 'ShowOrdersController' }). otherwise({ redirectTo: '/addOrder' }); $locationProvider.html5Mode({ enabled: true,requireBase: false }); }]); sampleApp.controller('AddOrderController',function($scope) { $scope.message = 'This is Add new order screen'; }); sampleApp.controller('ShowOrdersController',function($scope) { $scope.message = 'This is Show orders screen'; });
在index.html中
<!DOCTYPE html> <head> </head> <h1>weclome to test!</h1> <body ng-app="phonecatApp" > <div ng-view></div> <script src="//code.angularjs.org/1.2.20/angular.js"></script> <script src="//code.angularjs.org/1.2.20/angular-route.js"></script> <script src="static/app.js"></script> </body> </html>
在add_order.html中
<h2>Add New Order</h2> {{ message }}
在show_order.html中
<h2>Show Orders</h2> {{ message }}