angular 1x -- Ui-Router Dome

ui-router 笔录

HTML


JS
var myApp = angular.module('app', ['ui.router'])
myApp.config(function($stateProvider) {
  var homeState = {
    name: 'home',
    url: '/home',
    template: home
  }

  var aboutState = {
    name: 'about',
    url: '/about',
    template: about
  }
  
  var stateArr = [
    homeState,aboutState
  ]
  
  stateArr.forEach(function(e){
    $stateProvider.state(e)
  })
  
})
重定向
myApp.config(['$stateProvider', '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider) {
        $urlRouterProvider
            // 路由重定向
            .when('/', '/home')
            .otherwise('/');
    }
])

你可能感兴趣的:(angular 1x -- Ui-Router Dome)