为什么当我尝试在Ionic中使用列表时会出现此JavaScript错误
Why am I getting this JavaScript error when I try use lists in Ionic?
每次我尝试在我的应用程序中使用列表时,它都不起作用,我打开了开发工具,由于某些原因,我收到了以下错误,我对这些语言是新手,因此非常感谢您的帮助。我试着通过函数声明一个var,因为我认为这是错误告诉我的,但这没有奏效。
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>calorific</title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="calorific" ng-controller="calCtrl">
<ion-pane>
<ion-content>
<p></p>
<div class="card">
<div class="item item-text-wrap">
This is a basic Card which contains an item that has wrapping text.
</div>
</div>
<ion-list>
<ion-item ng-repeat="items in item"{{items.name}}> </ion-item>
</ion-list>
</ion-content>
</ion-pane>
</body>
</html>
JS:
angular.module('calorific', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
app.controller("calCtrl", function($scope) {
$scope.items= [
{name: 'apple'},
{name: 'banana'},
{name: 'banana'},
{name: 'banana'}
]
});
错误:
GET http://localhost:8100/css/style.css
app.js:17 Uncaught ReferenceError: app is not defined
ionic.bundle.js:19526 Error: [ng:areq] Argument 'calCtrl' is not a function, got undefined
http://errors.angularjs.org/1.3.13/ng/areq? p0=calCtrl&p1=not%20a%20function%2C%20got%20undefined
at REGEX_STRING_REGEXP (ionic.bundle.js:7982)
at assertArg (ionic.bundle.js:9499)
at assertArgFn (ionic.bundle.js:9509)
at ionic.bundle.js:16350
at ionic.bundle.js:15518
at forEach (ionic.bundle.js:8250)
at nodeLinkFn (ionic.bundle.js:15505)
at compositeLinkFn (ionic.bundle.js:14997)
at publicLinkFn (ionic.bundle.js:14876)
at ionic.bundle.js:9369
在这一行中,您指定了app
app.controller("calCtrl", function($scope) {
但它在任何地方都没有定义。
要么删除app
,它将像:
angular.module('calorific', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.controller("calCtrl", function($scope) {
$scope.items= [
{name: 'apple'},
{name: 'banana'},
{name: 'banana'},
{name: 'banana'}
]
});
否则,使用如下:
angular.module('calorific').controller("calCtrl", function($scope) {
相关文章:
- 用于查询错误转换的角度资源返回列表
- 为什么当我尝试在Ionic中使用列表时会出现此JavaScript错误
- 参数列表Three.js之后的未捕获语法错误:缺少)
- JavaScript类列表选择器错误
- 参数列表后缺少未捕获的语法错误)
- 如何将对象插入对象列表的开头,当它有 unshift 不是函数错误
- 属性列表后缺少}语法错误
- 未捕获的类型错误:对象#<节点列表>没有方法'addEventListener'
- 在列表项中插入错误值的文本输入
- 下拉列表中的选定索引在未选择任何值时引发错误
- 参数列表后的未捕获语法错误:缺少)
- 使用 Angular.js 使用多选下拉列表时出现 [$compile:multidir] 错误
- 在javascript错误中将json列表传递给数组
- 如何更新列表项由jQuery AJAX调用添加的ASP Dropdown:错误无效的回发或回调
- Json下拉列表错误
- 求解参数列表错误后的WebDriverException:缺少)
- fql获取好友列表错误
- Adobe Javascript If/Else下拉列表错误
- JQuery丢失)后的参数列表错误:
- HTML 中的动态下拉列表错误