DB (mongoDB)에서 데이터를 가져 오려고 할 때 $http.get
에 문제가 있습니다.
평균 스택을 사용하고 있습니다. 또한
angular.module('wildroseApp')
.controller('WildroseComponent', function($scope, $http){
$http.get('/api/wildrose')
.success(function (data) {
$scope.wildrose = data;
console.log($scope.wildrose);
})
.error(function (err) {
alert('Error!');
});
})
.component('wildrose', {
templateUrl: 'app/wildrose/wildrose.html',
controller: WildroseComponent,
controllerAs: Wildrose
});
, 나는 한 번 더 질문이 있습니다
내가 구성 요소의 controllerAs
를 사용하고, 브라우저가
Uncaught ReferenceError: Wildrose is not defined
말한다을하지만 그것을 제거하면, 그것은 확인을 할 것이다.
그냥 생성자에서 약간의 코드를 추가합니다 : 나는 다음과 같이 해결을 시도
controllerAs: "wildrose"
당신 유무 :
class WildroseComponent {
constructor($http) {
this.$http = $http;
this.wildrose = [];
}
$onInit(){
this.$http.get('/api/wildrose')
.then(response => {
this.wildrose = response.data;
console.log(this.wildrose);
});;
}
}
어떤 AngularJs 버전을 사용하고 있습니까? –
버전은 1.5.0입니다. –
질문/문제가 무엇입니까? "효과가없는"것은 정확히 의미합니까? – dfsq