0
過去幾天我一直在使用angularjs進行操作,並且現在我已經開始使用javascript對象來打磚塊了。Javascript對象在視圖中沒有使用Angular js更新
我想在視圖中表示對象的屬性,然後在頁面加載更改該對象並使視圖發生更改後。即
的Html
<div ng-controller = "MainCtrl">
{{object.attribute}} //Expect A, and then B. Just get A
</div>
的Javascript
app.controller('MainCtrl', ['$scope', function($scope) {
$scope.message_object = new object("A");
$scope.replace_message = function(){ //Happens sometime after page load
alert("Replacing...");
$scope.object = new object("B");
}
}]);
function object(attribute){
this.attribute = attribute;
}
不知道如果我失去了一些東西,或者只是有框架結構的根本誤解。無論哪種方式,一些幫助,將不勝感激:)我當前的代碼是:
http://plnkr.co/edit/3fF0zSyZaIvVsYk8dvWf?p=preview
它的設計更新對象時,按下一個鍵