标签:
一、选择angular-ui-router的好处
二、简单示例,步骤如下:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="js/angular.js"></script> <script src="js/angular-ui-router.js"></script> <script src="js/app.js"></script> </head> <body ng-app="myApp"> <h1>AngularJS Home Page</h1> <div ui-view=""></div> </body> <html>
<div> <div> <span style="width: 100px" ui-sref=".Page1"><a href="">Page-1</a></span> <span style="width: 100px" ui-sref=".Page2"><a href="">Page-2</a></span> <span style="width: 100px" ui-sref=".Page3"><a href="">Page-3</a></span> </div> <div> <div ui-view="" /> </div> </div>
<div > <div> <h1>Page 1 content goes here...</h1> </div> </div>
var myApp = angular.module("myApp", [ 'ui.router' ]); myApp.config(function($stateProvider, $urlRouterProvider) { $urlRouterProvider.when("", "/PageTab"); $stateProvider.state("PageTab", { url : "/PageTab", templateUrl : "PageTab.html" }).state("PageTab.Page1", { url : "/Page1", templateUrl : "Page1.html" }).state("PageTab.Page2", { url : "/Page2", templateUrl : "Page2.html" }).state("PageTab.Page3", { url : "/Page3", templateUrl : "Page3.html" }); });
标签:
原文地址:http://blog.csdn.net/u010834071/article/details/45194487