我正在尝试使用离子框架和打字稿开发应用程序,但我在ionic.bundle.js上收到此错误:
rrror:[ng:areq]参数'MainViewModel'不是函数,未定义
这是我的html页面:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>TodoApp</title>
<script src="cordova.js"></script>
<link rel="stylesheet" href="css/index.css" />
<link href="Content/ionic.css" rel="stylesheet" />
<script src="scripts/ionic.bundle.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script src="scripts/app/ViewModels/MainViewModel.js"></script>
<script src="scripts/app/index.js"></script>
</head>
<body ng-app="app" ng-controller="MainViewModel">
<div class="bar bar-header bar-light">
<h1 class="title">Todo</h1>
</div>
<ion-content class="has-header">
<div class="list">
<div class="item item-input-inset">
<label class="item-input-wrapper">
<input type="text" placeholder="New Todo"/>
</label>
<div class="button button-small">Add</div>
</div>
</div>
</ion-content>
</body>
</html>
在这里我正在设置角度:
angular.module("app", ["ionic"])
.controller("MainViewModel", MainViewModel);
有人认出这个问题吗?
答案 0 :(得分:1)
你缺少控制器内部的回调功能 这是错误
angular.module("app", ["ionic"])
.controller("MainViewModel", function ($scope){
//yourcode
});