Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.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 angularjs-$state.go更改url但不加载html页面_Javascript_Angularjs_Routing_Angular Ui Router_State.go - Fatal编程技术网

Javascript angularjs-$state.go更改url但不加载html页面

Javascript angularjs-$state.go更改url但不加载html页面,javascript,angularjs,routing,angular-ui-router,state.go,Javascript,Angularjs,Routing,Angular Ui Router,State.go,我正在用angularJS练习布线,遇到了一个问题。我上网查了查,尝试了很多方法,但都没有解决我的问题。你能帮我吗 我对$state.go函数有问题。它会更改url,但不会加载html文件。我查看了控制台,但没有出现错误 app.js (function(){ var app = angular.module('myTrello', ['date-directives', 'ngRoute', 'ui.router']); app.controller("mainCt

我正在用angularJS练习布线,遇到了一个问题。我上网查了查,尝试了很多方法,但都没有解决我的问题。你能帮我吗

我对$state.go函数有问题。它会更改url,但不会加载html文件。我查看了控制台,但没有出现错误

app.js

(function(){
    var app = angular.module('myTrello', 
    ['date-directives', 'ngRoute', 'ui.router']);

    app.controller("mainCtrl", ['$scope', '$http', '$state', '$route', function($scope, $http, $state, $route){
    $scope.title = "Welcome to my trello";
    $http.get("http://quotes.rest/qod.json")
    .then(function(response) {
        let quoteInfo = response.data.contents.quotes[0];
        $scope.quote = quoteInfo.quote;
        $scope.author = quoteInfo.author;
    });
    $scope.go = function(path) {
        $state.go(path, {});
    };
}]);

app.controller("boardCtrl", function(){

});

// app.controller("routeCtrl", function($scope, $routeParams) {
//     $scope.param = $routeParams.param;
// });

app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){
    $urlRouterProvider.otherwise('/home');
    $stateProvider
        .state('home', {
            url: '/home',        
            templateUrl: 'index.html',
            controller: 'mainCtrl'
        })
        .state('boards', {
            url: '/boards',
            templateUrl: 'boards/board.html',
            controller: 'boardCtrl'
        })
        // .state('/boards/:param', {
        //     url: '/boards/:param',
        //     templateUrl: 'index.html',
        //     //controller: 'boardCtrl'
        // })
}]);
})();
index.html(重要部分)


{{title}}
今天的报价
{{quote}}
作者:{{作者}
我的董事会
board.html

<html>
<h1>Boards</h1>
</html>

董事会

当您使用
ui路由器时,您需要使用
ui-view
指令而不是
ng-view
,因此将代码更改为

<div ui-view></div>

而不是

<div ng-view></div>

当您使用
ui路由器时,您需要使用
ui-view
指令而不是
ng-view
,因此将代码更改为

<div ui-view></div>

而不是

<div ng-view></div>