私はいくつかのJSONファイルから情報を取るAngularアプリケーションを持っています。 最初のJSONファイルには、都市とマネージャに関するデータが含まれています。このように:AngularJSのリンクをクリックしても情報が更新されません。私は{{値}}を持っていますが、データはありません
すべての都市のページを作成するために使用します。 私のURLは次のようになります。...index.html#/cities/veliky_novgorod/
、...index.html#/cities/biisk/
、...index.html#/cities/biisk/mobile/
など
すべてが正常に動作しますが、私は他のJSON(スコープ)から別の情報を1ページから行くしようとすると、ロードされません。私はいつも持っているページを変更した後{{ value }}
しかし私は手動でリフレッシュを行うと、すべて正常に戻ります。 つまり、リンクをクリックした後に新しいページを再読み込みするにはどうすればいいですか?私はwindow.location.reload()
を使用しようとしましたが、動作しません。私のコントローラの
var curryApp = angular.module('CurryApp', [
'ngRoute',
'curryControllers'
]);
curryApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'link_list.html',
controller: 'CurryListCtrl'
}).
when('/cities/:cityId/', {
templateUrl: 'template-total.html',
controller: 'CurryDetailCtrl'
}).
when('/cities/:cityId/mobile/', {
templateUrl: 'template-mobile.html',
controller: 'CurryMobileCtrl'
}).
otherwise({
redirectTo: '/'
});
}]);
:以下
<li ng-repeat="city in cities">
<a href="#/cities/{{city.link}}" ng-click="reloadRoute()">{{city.manager}}</a>
</li>
私のモジュールとコントローラ
var curryControllers = angular.module('curryControllers', []);
curryControllers.controller('CurryListCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('cities.json').success(function(data) {
$scope.cities = data;
});
}]);
curryControllers.controller('CurryDetailCtrl', ['$scope', '$routeParams', '$http', '$route',
function($scope, $routeParams, $http, $route) {
$scope.reloadRoute = function(){window.location.reload();}
$scope.cityId = $routeParams.cityId;
$http.get('cities.json').success(function(data) {
$scope.cities = data;
$http.get('paidbc.json').success(function(data2) {
$scope.paidBc = data2;
$scope.isActive = function(item) {
return item.link === $scope.cityId;
};
});
});
}]);
curryControllers.controller('CurryMobileCtrl', ['$scope', '$routeParams',
function($scope, $routeParams) {
$scope.cityId = $routeParams.cityId;
}]);
残念ながら問題は解決しません。最初のページはうまく読み込まれますが( 'ng-repeat'が動作します)、クリックしてURLを変更した後も同じ問題があります。私は '{{}} 'を持っており、' ng-repeat'は動作しません。 URLを変更してもロードされないamChartsプロットがある –
申し訳ありませんが、すべて正常に動作します。素晴らしい! –