Javascript app.js中的控制器不是';我在爱奥尼亚项目工作
在我的爱奥尼亚项目app.js中,我编写了一些代码,但当我在index.html文件中使用控制器时,这些代码不起作用 我如何让它工作 app.js:Javascript app.js中的控制器不是';我在爱奥尼亚项目工作,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,在我的爱奥尼亚项目app.js中,我编写了一些代码,但当我在index.html文件中使用控制器时,这些代码不起作用 我如何让它工作 app.js: var app= angular.module('starter', ['ionic']); app.controller('ListCtrl',function($scope) { $scope.notes = [ { title:'First note'
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:
<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>
信息说明
{{note.title}
您在JSON
中忘记了逗号。在您的控制器中
,使用以下命令重试:
app.controller('ListCtrl',function($scope)
{
$scope.notes =
[
{
title:'First note',
description:'This is my first note'
},
{
title:'Second Note',
description:'second note'
}
];
});
你能详细说明什么不起作用吗?你为index.html定义了什么状态?@Habkamas我不太明白,但我没有使用任何状态,我想我只是在app.js中编写了一个控制器代码(你看到的代码)并试图在ionic blank模板的index.html文件中使用它。为了更好地理解该特定代码的使用。但它不起作用…我浏览了ionic framework网站的文档,但仍然不起作用…:(非常感谢您…..我现在无法投票表决您的答案,因为我的声誉低于15。一旦我获得声誉,我将投票表决您的答案….:D@MD.SazidHasanDip你不能推翻他的答案,但你仍然可以接受