각도 앱에 경로를 설정하기 만하면됩니다. 내가 /
$http
전화의 뒤쪽으로 #/view/:id
로 이동하면 첫 번째보기, List
프레젠테이션
function ListController($scope, $http)
{
$scope.error = null;
$scope.presentations = null;
$scope.requesting = true;
$scope.currentTitle = '-1';
$data = {
'type' : 'presentations'
};
$http.post('resources/request.php', $data, {timeout:20000})
.success(function(data, status, headers, config)
{
$scope.requesting = false;
$scope.presentations = data;
})
.error(function(data, status, headers, config)
{
$scope.requesting = false;
log(status + ', data:" ' + data + '"');
}
}
);
}
내 노선은
angular.module('main',[]).
config(function($routeProvider) {
$routeProvider.
when('/', {controller:ListController, templateUrl:'resources/views/list.html'}).
when('/view/:id', {controller:VforumController, templateUrl:'resources/views/vforum.html'}).
otherwise({redirectTo:'/'});
});
내가 가지고있는 문제입니다 다시 전화를받습니다. 앱에 처음 들어가서 처음으로로드 된 동일한 데이터를 참조하도록로드하려면 어떻게해야합니까?
각도 이외의 변수를 만들고 처음로드 된 데이터와 동일하게 설정하려고했습니다. 그런 다음 ListController
에서 기본적으로 if data is null, do the $http call else set $scope.data = data
을 수행했지만 작동하지 않았습니다. 목록보기가 비어 있습니다. $scope.data
은 내 목록을 만드는 것입니다.
당신을 했 컨트롤러에'$ route'를 넘겨주고'$ http.post()'앞에있는''$ routeParams' (http://docs.angularjs.org/api/ng.$routeParams)를 검사 해보십시오. 그럴 가치가있어. – couzzi
나는 전에'$ routeParams'를 사용하지 않았습니다. 일반적으로'$ routes'. 이번이 처음입니다. 나는 이것에 대해 살펴볼 것입니다. 감사합니다. – Ronnie