【问题标题】:Error loading scope into jade template using angular使用角度将范围加载到玉模板时出错
【发布时间】:2014-01-14 20:19:14
【问题描述】:

我正在开发一个简单的 angular/jade 模板,但在尝试将信息加载到我的模板时出现错误。

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"
        }
    }; 
}

我不断收到此错误:

500 参考错误:/Users/AllanAraujo/Desktop/testapp 5/views/index.jade:7
5| div(ng-controller='AppCtrl')
6| h1 安古莱尔
> 7| ul(ng-app=ng-repeat="机场中的机场")
8| li {{ airport.code }}
9| li {{ airport.name }}
10| li {{ airport.destination }}

分配中的左侧无效

我是玉石/角度的新手,所以我对这个错误是什么感到困惑。任何帮助表示赞赏。

【问题讨论】:

    标签: angularjs pug


    【解决方案1】:

    我相信是因为 index.jade 中的以下行:

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

    ng-appng-repeat 是属性。您需要使用逗号分隔它们:

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

    【讨论】:

      猜你喜欢
      • 2014-02-01
      • 1970-01-01
      • 2014-02-02
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 2014-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多