[英]controller in app.js isn't working for ionic project
In my Ionic project, in app.js, I wrote some code but it doesn't work when I use the controller in index.html file. 在Ionic项目的app.js中,我编写了一些代码,但是当我在index.html文件中使用控制器时,它不起作用。
How do I make it work? 我该如何运作?
app.js: app.js:
var app= angular.module('starter', ['ionic']);
app.controller('ListCtrl',function($scope)
{
$scope.notes =
[
{
title:'First note'
description:'This is my first note'
},
{
title:'Second Note'
description:'second note'
}
];
});
index.html: index.html的:
<body ng-app="starter">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">InfoNote</h1>
</ion-header-bar>
<ion-content ng-controller="ListCtrl">
<div class ="list">
<div class ="item" ng-repeat="note in notes" >
{{note.title}}
</div>
</div>
</ion-content>
</ion-pane>
</body>
You forgot comma in your JSON
. 您在
JSON
忘记了逗号 。 In your controller
, try again with this : 在您的
controller
,再试一次:
app.controller('ListCtrl',function($scope)
{
$scope.notes =
[
{
title:'First note',
description:'This is my first note'
},
{
title:'Second Note',
description:'second note'
}
];
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.