user516883
user516883

Reputation: 9378

Why node js data wont display in Jade View engine Angular app

I am new to Angular Js. I was building a new project and for some reason. My application will not display data after the angular div but will display it before the angular div.

My node application is pulling some test data from mongodb that ends up looking something very simple like {Message:"This is a message"}

My index.jade file is pretty simple. Displaying some angular info plus the mongodb data from the route call.

extends ../includes/layout.jade

block main.js-content
    section.content
    h2= monogoMessage
        div(ng-view)

The data is displayed fine in above code. Everything works my h2=monogoMessage is displayed. But now if I put the h2= mogoMessage after my div(ng-view) it will not work. Not working meaning nothing is displayed or rendered(no h2 at all). Very confused on why this is happening. Am I missing something? The route has data all the time.

block main.js-content
    section.content
        div(ng-view)
h2= monogoMessage  /*THIS WILL NOT SHOW ANYTHING AT ALL */

Upvotes: 0

Views: 98

Answers (1)

Pier-Luc Gendreau
Pier-Luc Gendreau

Reputation: 13814

Take a closer look at the indentation, the h2 is outside the block. If you indent it at the same level as section, it will be rendered correctly.

block main.js-content
    section.content
        div(ng-view)
    h2= monogoMessage

Also, in your example above, you are nesting ng-view inside the h2, which was probably not your intention.

Upvotes: 1

Related Questions