您好,我是Angularjs的新手。以下是我的代码:
.html文件:
<!DOCTYPE html>
<html ng-app="showcase.angularWay.dataChange">
<head>
<script src='js/jquery-1.11.3.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.min.js"></script>
<script src='js/main.js'></script>
</head>
<body>
<div ng-controller="AngularWayChangeDataCtrl as showCase">
<input type='text' value="{{showCase.demo}}" />
{{showCase.demo}}
</div>
</body>
</html>
.js文件:
angular.module('showcase.angularWay.dataChange', ['ngResource'])
.controller('AngularWayChangeDataCtrl', AngularWayChangeDataCtrl);
function AngularWayChangeDataCtrl($scope)
{
var vm = this;
vm.demo = "hello";
}
当我在输入字段中输入任何新文本时,它不会更新以前显示的文本。 (如附图所示)。