서비스 요청에서 돌아와서 내보기를 업데이트 할 수없는 것 같습니다. 은 '깨지지 않았 음' 콘솔에 절대 빠져 나가지 않습니까?
서비스는 [{테스트 '서비스 workies'}] 반환
app.controller('foo-controller', ['fooService','$scope', function (fooService,$scope) {
var ctrl = this;
ctrl.Results = [{ test: 'no workies' }];
ctrl.Search = function() {
fooService.GetFoos().then(function (result) {
console.log('test');
console.log(ctrl.Results);
ctrl.Results = result;
console.log(ctrl.Results);
$scope.$apply(function() {
console.log('not broken');//never fires!!
ctrl.Results = [{test : 'workies' }]
});
});
};
return ctrl;
}]);
app.directive('fooLogo', function() {
return {
restrict: 'E',
templateUrl: './App/Templates/foo.html',
controller: 'foo-controller',
controllerAs: 'f'
};
});
편집 foo는 서비스
.service('fooService', ['$http', function ($http) {
return $http.get("https://www.googleapis.com/books/v1/volumes?q=harry+potter").then(
function(result){ return [{ test: 'service workies'}]},
function(error) { return [{test: 'service call no workies'}]);
당신이 fooService''에 대한 코드 등을 게시 할 수 있습니다 : 여기
가 동작하는 예제와 plunker입니다 제발? – pje
@pje가 서비스를 추가했습니다. – gh9
''test''가 기록 되나요? –