I've been mucking around with angularjs for the last few days, and have hit a brick wall now that I've started mucking about with javascript objects.
I'm trying to represent an attribute of an object in the view, and then after page load change that object and have the view change. I.e
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;
}
Don't know if I'm missing something, or just have a fundamental misunderstanding of the structure of the framework. Either way some help would be appreciated :) My current code is at:
http://plnkr.co/edit/3fF0zSyZaIvVsYk8dvWf?p=preview
it's designed to update the object when a key is pressed