代码如下,为什么页面的文本在2秒之后没有变成 world
<body ng-app="myApp">
<div ng-controller="asyncCtrl">
<input type="text" ng-model="name">
<span>{{name}}</span>
</div>
<script src="../../bower_components/angular/angular.js"></script>
<script type="text/javascript">
var myApp = angular.module('myApp',[]);
myApp.controller('asyncCtrl',function($scope,$http){
$scope.name = "hello";
setTimeout(function(){
$scope.name = "world";
},200);
})
</script>
</body>
另,通过$http拿到的后台数据,如何赋值给model,然后自动更新视图?
PS:好吧,其实两个问题都是一个问题。。
相关分类