首页 > Web开发 > 详细

AngularJS 单视图 view

时间:2015-06-03 13:56:49      阅读:201      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!