0
以下是我的榜樣AngularJS routeParams - 文件未發現異常
var myApp = angular.module('MySampleApp', ['ngRoute']);
myApp.controller('SampleCtrl', ['$scope', '$routeParams', function($scope, $routeParams) {
$scope.employee = {
id: 5,
name : 'balaji',
sal : 5000
};
$scope.a = $routeParams.a;
$scope.b = $routeParams.b;
}]);
myApp.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
template : "<strong> This is my routeProvider sample </strong>"
})
.when('/calc/:a/:b', {
templateUrl: "calc.htm",
controller: "SampleCtrl"
})
.otherwise({
template : "<strong> No CONTENT </strong>"
})
}]);
a01.htm
<!DOCTYPE html>
<html ng-app="MySampleApp">
<head>
<title>RoteParams example</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8 /angular-route.js"></script>
<script src="SampleCtrl.js"></script>
</head>
<body>
<div ng-controller="SampleCtrl">
{{employee.id}} , {{employee.name}} , {{employee.sal}}
<div>
<a href="#/calc/4/5"> Sum </a>
</div>
<div ng-view> </div>
</div>
</body>
</html>
我已經安裝了新公共管理和使用以下命令啓動服務器:
C:\Users\xyz>http-server c:\Users\xyz\Descktop\practice
Starting up http-server, serving c:\Users\xyz\Descktop\practice
Available on:
http://10.0.0.117:8081
http://127.0.0.1:8081
當我嘗試通過訪問該頁面a01.htm http://localhost:8081/a01.htm
和http://localhost:8081/a01.htm#/calc/4/5
, 兩個鏈接都扔
「這本地主機頁面無法找到
沒有網頁被發現的Web地址:http://localhost:8081/a01.htm」
此外,在服務器上它顯示:
pleWebKit/537.36(KHTML ,像Gecko)Chrome/55.0.2883.87 Safari/537.36「[Sat Dec 24 2016 19:54:07 GMT-0800(Pacific Standard Time)]」GET /a01.htm「錯誤(404):」未找到「
你確定服務器啓動了嗎? –
是的,我啓動了服務器..其他如何來聽取URL GET/a01.htm? –
'dir c:\ Users \ xyz \ Descktop \ practice'的輸出是什麼? –