i have this code and i can't see where is the source of problem, i don't get any error in the chrome console my controller :
function notifController($scope) {
$scope.refreshMsgs = function () {
$.post("notification-center-trait.aspx")
.success(function (data) {
$("#loadedthings").html(data);
newMsgs = JSON.parse($("#label1").html());
$scope.msgs = newMsgs;
});
}
$scope.refreshMsgs();
}
label1
and label2
are loaded correctly inside a div loadedthings;
newMsgs in the console is parsed just the way it should;
i had it working for other pages but it seems that i missed something on this one.i have <html ng-app>
tag :
<div ng-controller="notifController">
<div class="row">
{{msgs.length}} new msgs :
<table class="table">
<tbody >
<tr ng-repeat="msg in msgs">
<td>
{{msg.sender}}
</td>
<td>
{{msg.message}}
</td>
<td>
{{msg.date}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
i get 'undefined' in the console when i execute this : angular.element($0).scope()
$0
is working?. I don't know what you're doing with that... – m59 Jan 15 '14 at 1:54angular.element
belongs in a directive. Angular makes the scope property available wherever you need it, other than maybe rare exceptions, so you should not need to access an element or a scope this way. – m59 Jan 15 '14 at 2:00angular.element($0).scope()
in chrome console just to see what's happening in my scope link but i get 'undefined' – zerzer Jan 15 '14 at 2:01$scope.foo = 'test'
and in your markup:{{foo}}
. Perhaps your ajax call just isn't coming through? If the controller truly isn't working, something else (not in this code) is the issue. – m59 Jan 15 '14 at 2:05{{foo}}
. You definitely have a simple error that you could debug with the console, I'm certain. Also, Angular has the$http
for ajax calls, you should be using that rather than jQuery. – m59 Jan 15 '14 at 2:50