Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角度UI嵌套状态模板未加载_Angularjs_Angular Ui Router - Fatal编程技术网

Angularjs 角度UI嵌套状态模板未加载

Angularjs 角度UI嵌套状态模板未加载,angularjs,angular-ui-router,Angularjs,Angular Ui Router,Index.html <!doctype html> <html ng-app="testApp"> <head> <meta name="viewport" content="width=device-width"> <link rel="Shortcut Icon" type="image/ico" href="img/favicon.png"> <link rel="stylesheet" h

Index.html

    <!doctype html>
<html ng-app="testApp">
<head>
    <meta name="viewport" content="width=device-width">
    <link rel="Shortcut Icon" type="image/ico" href="img/favicon.png">
    <link rel="stylesheet" href="styles/vendor.css">
    <link rel="stylesheet" href="styles/app.css">
</head>
<body id="wrap">
<div ui-view></div>
<script src="js/vendor.js"></script>
<script src="js/app.js"></script>
</body>
</html>
app.js

"use strict";
var TestApp = angular.module("testApp",["ui.router"])
    .config(["$urlRouterProvider","$stateProvider",function(a,b) {
    a.otherwise("test", {
        url: "/test",
        title: "Test",
        template:"<p>Test</p>"
    })
}]);
这是我的目录结构 特斯塔普 JS->app.JS index.html


请更正我的代码

UI路由器是关于状态的。所以我们必须调用$stateProvider.state来定义状态。$urlRouterProvider方法。否则,应使用服务器进行默认导航-如果url与注册状态不匹配:

.config(["$urlRouterProvider","$stateProvider"
,function($urlRouterProvider,$stateProvider) {

  // instead of this
  a.otherwise("test", {
  // we need to call .state
  $stateProvider.state("test", {
    url: "/test",
    title: "Test",
    template:"<p>Test</p>"
  })

  // and also some defaults
  // but not state name 'test', it should be url '/test'
  $urlRouterProvider.otherwise("/test")

宾果游戏和OP Plunker在这里