user2615699
user2615699

Reputation:

Error loading scope into jade template using angular

I am working on a simple angular/jade template, and I am getting an error wen trying to load in information to my template.

layout.jade:

doctype
html(ng-app)
    head
        title= title
        script(type='text/javascript', src='javascripts/lib/angular.min.js')
        script(type='text/javascript', src='javascripts/lib/angular-resource.min.js')
        script(src='//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js')
        script(type='text/javascript', src='public/javascripts/app2.js')
        link(rel='stylesheet',type='text/css', href='/stylesheets/boostrap.css')
    body
        block content

index.jade:

extends layout

block content
    h1= title
    div(ng-controller='AppCtrl')
        h1 Angulair
        ul(ng-app=ng-repeat="airport in airports") 
            li {{ airport.code }}
            li {{ airport.name }}
            li {{ airport.destination }}

app2.js:

function AppCtrl ($scope) {
    $scope.airports = {
        "PDX": {
            "code": "PDX", 
            "name": "Portland", 
            "destination": "Toronto"
        }, 
        "LAX": {
            "code": "LAX", 
            "name": "Los Angeles", 
            "destination": "Toronto"
        }
    }; 
}

I keep getting this error:

500 ReferenceError: /Users/AllanAraujo/Desktop/testapp 5/views/index.jade:7
5| div(ng-controller='AppCtrl')
6| h1 Angulair
> 7| ul(ng-app=ng-repeat="airport in airports")
8| li {{ airport.code }}
9| li {{ airport.name }}
10| li {{ airport.destination }}

Invalid left-hand side in assignment

I am new to jade/angular so I am kind of confused as to what this error is. Any help is appreciated.

Upvotes: 2

Views: 603

Answers (1)

callmekatootie
callmekatootie

Reputation: 11238

I believe it is because of the following line in index.jade:

ul(ng-app=ng-repeat="airport in airports")

ng-app and ng-repeat are attributes. You need to separate them using comma:

ul(ng-app, ng-repeat="airport in airports")

Upvotes: 1

Related Questions