用anglajs怎样改变html的url,angularjs - $ state.go更改url但不加载html页面

我正在练习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}}

Today's quote

{{quote}}
By: {{author}}

My boards

board.html

Boards

2017-07-28

Nina

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值