I am a newbie to angular js,I have a js background and was stuck into something:-
I want to append data into the HTML with the help of directive.
I am storing the value (ie HTML) in a string..But it is giving value..one of the is escaping string. Somehow I am not been able to implement it.
The below is my code.
woi.directive("addbuttons",['$rootScope','userAPI', function($rootScope,userAPI,$compile){
return function(scope, element, attrs){
element.bind("click", function(){
scope.count++;
//var abc= scope.loadRated(pageno);
userAPI.topRated({userid: $rootScope.getUser().userid}, function (r, $scope, div){
if(!$rootScope.device.isMobile && !$rootScope.device.isTablet && !$rootScope.device.isTouch ) {
var topRatedList = r.gettopratedhomepage.topratedprogrammelist;
var str='';
for(var i=0;i<topRatedList.length;i++)
{
str+=topRatedList[i].actualname;
var str="
<div class='thumb'>
<div ng-show='topRatedList[i].isrecommended==1' class='favorite-ribbon'></div>
<div class='player'></div>
<div class='image' style='background-image:url({{topRatedList[i].imagefilepath}});'>
<a ng-click='playVideo(topRatedList[i].programmename,$event)' ng-show='hasVideo()' class='play' style='cursor:pointer'></a>
<a ng-href='#!/program/{{topRatedList[i].programmename | encodeUrl}}' ng-show='!hasVideo()' class='noPlay' ng-click='EncodeUrlWithDash(topRatedList[i].programmename,$event,'programme',topRatedList[i].channelid,topRatedList[i].programmeid,topRatedList[i].starttime)'></a>
</div>
<span class='time' ng-show='topRatedList[i].duration'>{{topRatedList[i].duration | videoLength}}</span>
<div class='user-actions' ng-controller='UserController'>
<a live-tooltip='Add to Favorite' ng-click='toggleFavorite(p, $event)' class='btn btn-small btn-purple-blue' ng-class='{active:topRatedList[i].isfavorite == \'1'}">
<i class="icon-favorite"></i>
</a>
<a live-tooltip="Reminder Alerts" ng-click='toggleReminder(p, $event)' class='btn btn-small btn-purple-blue' ng-class="{active:topRatedList[i].isreminder == '1'}" >
<i class="icon-reminder"></i>
</a>
<a live-tooltip='Add to Watchlist' ng-click='addToWatchlist(p, $event)' class='btn btn-small btn-purple-blue' ng-class="{active:topRatedList[i].iswatchlist == '1'}">
<i class="icon-watchlist"></i>
</a>
</div>
</div>
<div class="text-wrapper">
<h2 multiline-overflow><a title="{{topRatedList[i].programmename}}" href="#!/program/{{topRatedList[i].programmename | encodeUrl}}" ng-click="EncodeUrlWithDash(topRatedList[i].programmename,$event,'programme',topRatedList[i].channelid,topRatedList[i].programmeid,topRatedList[i].starttime)" >{{topRatedList[i].programmename}}
</a></h2>
<p class='infoChannel' live-tooltip-single-line= "{{topRatedList[i].channeldisplayname}}"><a href="#!/channel/{{topRatedList[i].channeldisplayname | encodeUrl}}" ng-click="EncodeUrlWithDash(topRatedList[i].channeldisplayname,$event,'channel',topRatedList[i].channelid,topRatedList[i].programmeid)">{{topRatedList[i].channeldisplayname}}
</a></p>
<p class='info'>{{topRatedList[i].starttime|featuredVideoTime}}</p>
</div>";
}
angular.element(document.getElementById('space-for-buttons')).append($compile("<div><button class='btn btn-default' data-alert="+scope.count+">Show alert #"+scope.count+"</button></div>")(scope));
}
});
});
};
}]);
I am getting the data from the userApi,and want to put it in the Html.
I just want to know the "angular" way to do it.
Thanks