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

$http.get in Angular doesn't work

I have problem with

when I am 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

In addition, I have one more question:

When I'm using
in component, my browser says

Uncaught ReferenceError: Wildrose is not defined

But, if remove it it would be OK.

I have tried solving it as follows:

Just add in the 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.