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_Uiview - Fatal编程技术网

Angularjs ui视图的小错误

Angularjs ui视图的小错误,angularjs,uiview,Angularjs,Uiview,在使用ui视图时,我有以下错误 在我的索引页上,我有如下内容: <body role="document" ng-app="MyApp"> <div ng-include="'./views/home.html'"></div> //scripts </body> <navigation></navigation> <div class="container-fluid"> <div

在使用ui视图时,我有以下错误

在我的索引页上,我有如下内容:

<body role="document" ng-app="MyApp">
  <div ng-include="'./views/home.html'"></div>
   //scripts
</body>
<navigation></navigation>
  <div class="container-fluid">
    <div class="row">
      <sidebar></sidebar>
      <div ui-view></div>
     </div>
  </div>
 app.config(function($stateProvider, $urlRouterProvider){
    $urlRouterProvider.otherwise('/');
 $stateProvider
   .state('home', {
     url: '/',
     templateUrl: 'views/dashboard.html' 
   });
 });
问题是:当我转到主页上的url“/”时,它不显示dashboard.html,它只显示home.html模板,因此我必须添加“/#/”以显示仪表板,再次单击相同的链接“/#/”后,仪表板隐藏,因此我必须在url上手动键入它才能再次看到它

有人有同样的问题吗

我正在使用angular上的最新版本

更新

如果我将所有逻辑移到home.html的索引页中,并直接调用它,而不使用ng include,它的工作原理就像charm一样,但是,这不是我需要的,我认为加载中存在一些问题,这是我误解的。

否则的功能没有发挥作用。您应该使用它来提供应该加载的状态,而不是复制状态定义。我认为你应该读代码

$urlRouterProvider.otherwise("/home");


是的,这是我的第一个想法,我只是在使用它时更新了它,我仍然有相同的问题这是在什么浏览器中?哦-我没有看到你在部分页面中有ui视图。这可能不受支持。您应该能够通过在ui路由器中使用并行视图和嵌套视图来实现您的功能。我认为您只需要花一些时间学习ui路由器提供的示例,就可以实现您的功能了!
$urlRouterProvider.otherwise("home");