Андрей Гузюк Андрей Гузюк - 7 months ago 18
Node.js Question

my $http.get in angular doesn't work

i have problem with $http.get when trying to get data from my db ( mongoDB )
I'm using mean stack .

.controller('WildroseComponent', function($scope, $http){
.success(function (data) {
$scope.wildrose = data;
.error(function (err) {
.component('wildrose', {
templateUrl: 'app/wildrose/wildrose.html',
controller: WildroseComponent,
controllerAs: Wildrose

and I have one more question yet;
When I'm using "controllerAs" in component my browser says

Uncaught ReferenceError: Wildrose is not defined

but if remove it all is ok

I solve it
just added in constructor a little bit code

class WildroseComponent {
constructor($http) {
this.$http = $http;
this.wildrose = [];
.then(response => {
this.wildrose = response.data;


ControllerAs requires string and not an object:

controllerAs: "wildrose"

Have you set up an endpoint at your server with node/express under /api/wildrose that returns a json string read from your database?

Please provide more code from your back-end and errors, otherwise it is hard to diagnose.