Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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
Javascript 角度ui路由器嵌套ui视图不工作_Javascript_Angularjs_Angular Ui Router - Fatal编程技术网

Javascript 角度ui路由器嵌套ui视图不工作

Javascript 角度ui路由器嵌套ui视图不工作,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我试图在angular中创建一个简单的嵌套管线,每当出现嵌套管线时,视图都不会弹出 路径为http://localhost:9000/#/home/hello我仍然只看到homeHello 为什么嵌套的ui视图没有拾取home.hello模板 呈现HTML 意见 你好 你好 有一个示例。我改变的是:“扩展父模板” 为了展示我们如何瞄准第一个ui-view=“ui-view”,它实际上被命名为,有一个新的状态Hello2: .state('home.hello2', { url: '/hel

我试图在angular中创建一个简单的嵌套管线,每当出现嵌套管线时,视图都不会弹出

路径为
http://localhost:9000/#/home/hello
我仍然只看到
homeHello

为什么嵌套的ui视图没有拾取home.hello模板

呈现HTML 意见

你好
你好
有一个示例。我改变的是:“扩展父模板”

为了展示我们如何瞄准第一个
ui-view=“ui-view”
,它实际上被命名为,有一个新的状态Hello2:

.state('home.hello2', {
  url: '/hello2',
  views : {
    'ui-view' : {
      templateUrl: 'tpl.hello2.html',
    }
  }
})
而这个状态现在实际上是针对命名的
ui view=“ui view
,因为它使用显式
views{}
定义。另一方面,状态hello使用隐式视图定义,可以这样表示:

  views : {
    '' : { // targeting unnamed ui-view=""
      templateUrl: 'tpl.hello2.html',
    }
  }

选中它

您的子状态上的ui sref应该包括父状态。例如,
ui sref=“home.hello”
AFAIKIt不需要这样做。这是相对路径。即使在那里,它也不起作用
<!-- home/home`.html -->
<section class="home">home<a ui-sref=".hello">Hello</a>
  <div ui-view="ui-view"></div>
</section>

<!-- home/hello.html -->
<section class="hello">Hello</section>
<section class="home">home
  <a ui-sref=".hello">Hello</a>
  <div ui-view="ui-view"></div>
  <div ui-view=""></div>      <!-- new line -->
</section>
.state('home.hello', {
  url: '/hello',
  templateUrl: 'tpl.hello.html',
})
.state('home.hello2', {
  url: '/hello2',
  views : {
    'ui-view' : {
      templateUrl: 'tpl.hello2.html',
    }
  }
})
  views : {
    '' : { // targeting unnamed ui-view=""
      templateUrl: 'tpl.hello2.html',
    }
  }