Angular异步改变model,为什么没有更新到view上?

代码如下,为什么页面的文本在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:好吧,其实两个问题都是一个问题。。


qq_笑_17
浏览 539回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java