码迷,mamicode.com
首页 > Web开发 > 详细

AngularJS 单视图 view

时间:2015-06-03 13:57:23      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:web   html   js   angular   view   

index.html

<html lang="en" ng-app="single_view">
<head>
  <script src="../jslib/angular.js"></script>
  <script src="../jslib/angular-route.js"></script>
  <script src="app.js"></script>
</head>
<body>

  <h1>below is the view information ... </h1>
  <div ng-view/>

</body>
</html>


app.js

angular.module(‘single_view‘, [‘ngRoute‘]).
  config([‘$routeProvider‘, function($routeProvider) {
  $routeProvider
  .when(‘/detail/:detailId‘, {templateUrl: ‘view/detail.html‘,controller: Detail})
  .otherwise({templateUrl: ‘view/hello.html‘});
}]);


function Detail($scope, $routeParams) {
  $scope.detailId = $routeParams.detailId;
}


view/detail.html

<h3>this is the detail information page ... </h3>

<h3>the detail id is {{detailId}}</h3>


view/hello.html

<h3>this is the hello page ... </h3>


AngularJS 单视图 view

标签:web   html   js   angular   view   

原文地址:http://antlove.blog.51cto.com/10057557/1657758

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!