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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.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 Angular ui.router,任何结果和错误_Angularjs_Angular Ui Router - Fatal编程技术网

Angularjs Angular ui.router,任何结果和错误

Angularjs Angular ui.router,任何结果和错误,angularjs,angular-ui-router,Angularjs,Angular Ui Router,我对我的观点有点问题。我尝试使用ui.router来配置我的路由,但它不起作用。我试着用控制台,但很清楚。我不知道我能做些什么来解决这个问题 (函数(){ "严格使用",; const-app=angular.module('myApp',['common.services','common.servicesMock','ui.router']); app.config(函数($stateProvider,$locationProvider){ $locationProvider.hashPre

我对我的观点有点问题。我尝试使用ui.router来配置我的路由,但它不起作用。我试着用控制台,但很清楚。我不知道我能做些什么来解决这个问题

(函数(){
"严格使用",;
const-app=angular.module('myApp',['common.services','common.servicesMock','ui.router']);
app.config(函数($stateProvider,$locationProvider){
$locationProvider.hashPrefix(“”);
$stateProvider
.state('newList'{
模板:“views/newsListView.html”,
url:“/news”,
控制器:“newsCtrl作为vm”,
});
//删除管线中的#
$locationProvider.html5Mode({
启用:对,
requireBase:错误
});
});
}())

维基
这是我要在浏览器中显示的视图


{vm.showCategories?“隐藏”:“Show”}Categories

{{cate}} 杰出的 {{newsItem.date | date}} {{newsItem.newsTitle} {{newsItem.NewsDescription.substring(0200)+“…”}

最后消息 {{newsItem.date | date}} {{newsItem.newsTitle} {{newsItem.NewsDescription.substring(0200)+“…”}


谢谢您的时间。

尽管您声明了状态,但您需要在第一次启动时实际“输入”状态。假设
newList
状态是您想要进入的状态,您可以通过两种方式进行操作:

  • 使用
    $urlRouterProvider
    路由到根目录下的
    /news

    app.config(function($stateProvider, $locationProvider, $urlRouterProvider) {
      $locationProvider.hashPrefix("");
    
      $urlRouterProvider.when('/','/news');
      $stateProvider
        .state('newList', {
          template: 'views/newsListView.html',
          url: '/news',
          controller: 'newsCtrl as vm',
        });
    
      //Delete the # in the routes
      $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
      });
    });
    
  • 通过
    。以角度运行
    方法

    app.run(['$state',function($state){
      $state.go('newList');
    }])
    

  • 虽然您声明了状态,但在第一次启动状态时,实际上需要“输入”状态。假设
    newList
    状态是您想要进入的状态,您可以通过两种方式进行操作:

  • 使用
    $urlRouterProvider
    路由到根目录下的
    /news

    app.config(function($stateProvider, $locationProvider, $urlRouterProvider) {
      $locationProvider.hashPrefix("");
    
      $urlRouterProvider.when('/','/news');
      $stateProvider
        .state('newList', {
          template: 'views/newsListView.html',
          url: '/news',
          controller: 'newsCtrl as vm',
        });
    
      //Delete the # in the routes
      $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
      });
    });
    
  • 通过
    。以角度运行
    方法

    app.run(['$state',function($state){
      $state.go('newList');
    }])