嗨,我是 AngularJS 的新手。这是我的 index.html 文件 http://clip2net.com/s/3oknPG6
<!doctype html>
<html ng-app="app">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.min.js"></script>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Angular route</title>
<link rel="stylesheet" href="css/style.css">
<link rel="author" href="humans.txt">
<script src="angular.js"></script>
<script src="node_modules/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="app/app.js"></script>
<style>
body {
padding: 20px;
}
</style>
</head>
<body>
<div ng-view></div>
<script src="js/main.js"></script>
</body>
</html>
这是 app.js 文件:
angular.module("app", ["ui.router"])
.config(function config($stateProvider){
$stateProvider.state("index", {
url:"",
controller: "FirstCtrl as first",
templateUrl: "templates/first.html"
})
})
.controller("FirstCtrl", function FirstCtrl(){
var first = this;
first.greeting = "First";
});
和 first.html 文件:
<input type="text" ng-model="first.greeting"/>
<div ng-class="first.greeting">{{first.greeting}}</div>
我无法在视图中获取数据,请帮我解决这个问题。我也收到此错误:无法读取未定义的属性“isDefined”。