I have this code in my application:
$scope.appendBets = function()
{
$.each($scope.phaseBets, function(i, bet)
{
var betElement = angular.element('<div ng-model="phaseBets[i]">Bet id: {{phaseBets[i].id}}</div>');
angular.element(document.querySelector('#betsHolder')).append(betElement);
$compile(betElement)($scope);
});
}
the $scope.phaseBets is loaded from $http.get.
Now the problem is that the {{phaseBets[i].id}} content not seen on the html page, I am getting this Bet id:.
I have seen this OS but it's not working for me, maybe because of the array. Is there anything wrong with my code?
Note
The thing is that by the I'd I will create an element (different for each id) so ng-repeat not helping that mutch.
jQuerysappend(or AngularJS's lite version) and start usingng-repeat. It does exactly the same thing with the added value that someone already thought of this issue and handled it for you. (I've been using AngularJS extensively, coming from a jQuery background, and found out in about a month that I don't need this kind of manual DOM manipulation at all anymore)ng-include(docs.angularjs.org/api/ng/directive/ngInclude) building the template URL based on each different ID. - Please trust us on this one: stop trying do do this the jQuery way and approach it the AngularJS way. It will take some time and you will read/ask a lot of questions on Stack Overflow, but it will be worth your time.ng-model. It only works oninputnodes.