私はアプリケーション内のルートを許可するために角$stateProvider
を使用しています。私はindex.html
を持っていると私は、次を使用して内部でHTMLコンテンツを変更しています...
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/app');
$stateProvider
.state('app', {
url: '/app',
templateUrl: 'templates/menu.html',
controller: 'AppCtrl'
})
.state('app.accounts', {
url: '/accounts',
templateUrl: 'templates/accounts.html'
})
});
アプリtemplate/menu.html
がindex.html
の内側に置かれている最初に開いた経路作品。この問題は、状態を変更しようとしたときに発生します。現時点で
app.accounts
に状態を変更するには、以下の見たい
app.controller('AppCtrl', function($scope, $ionicModal, $timeout) {
$scope.create = function() {
var linkHandler = Plaid.create({
env: 'tartan',
clientName: 'Example Project',
key: 'test_key',
product: 'connect',
//On success I want to change the state
onSuccess: function(token) {
window.location = '/app/accounts';
},
});
linkHandler.open();
}
});
上記、成功した場合に、私は状態を変更しようとしますが、window.location
が呼び出されたとき、私はエラーを取得する最初のルートが正常に動作しますので、私はこのエラーを取得する理由は...
net::ERR_FILE_NOT_FOUND (file:///app/accounts)
私はわかりません。どのように私はこれを修正することができますどのような考え?
OKので、私は 'のhref =「#/アプリ/アカウント」をやった'とエラーがなくなっていますが、代わりに私を 'app'状態(元の状態)にリダイレクトします。なぜなのかご存知ですか? – Bolboa
おそらくルートに何か問題があり、ルート定義の.otherwise()メソッドに入っています – MarBVI
しかし、$ stateProviderを使用している場合、リダイレクトを行う最良の方法は$ state.go( 'app.accounts ') – MarBVI