I do have a directive from which i'm trying to apply a bootstrap collapse function once the document is ready.
To do so I have to browse each object of a collection.
My directive looks something like this :
'use strict';
angular.module('app').directive("adScheduleTimeline",function($document) {
return {
restrict: 'E',
scope:{
ngModel: '='
},
templateUrl: '/partials/schedule/ad-schedule-timeline',
link: function (scope, el, attrs) {
scope.panelBaseId = attrs.collapsePanelBodyId;
scope.panelId = attrs.collapsePanelId;
$document.ready(function(){
console.log(scope.ngModel)
angular.forEach(scope.ngModel, function(value, key){
if (value.collapsed)
{
$("#" + scope.panelBaseId + "-" + key).collapse('show');
}
});
});
}
};
});
Once I load the page, the scope.ngModel
is undefined and therefore the collapse
function is not working.
Is there any better way to implement a similar function on page load.
For info, the collapse function is coming from Bootstrap2.x.x. i'm not using angular-ui-bootstrap.