0
我刚刚开始迁移到AngularJS,并且我已经遇到从angular-ui/ui-router框架出现问题。这是我到目前为止有:
angular
.module('testApp', ['ui.router'])
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/index/home");
$stateProvider
.state('index', {
abstract: true,
url: "/index",
template: "parent"
})
.state('index.home', {
url: "/home",
template: "child"
})
})
.controller("MainController", function() {
})
现在,运行此脚本重定向我http://example.com/#/index/home
但它只在页面上显示的父字符串。未显示子字符串。根据我的理解,这应该加载第一个模板,因为我们位于/#/index
域部分,然后是第二个模板,因为我们位于嵌套页面/#/index/home
。
有人可以帮助我解释为什么这不按预期工作?