I have an angular app in which I want to wait until data is bound to a selection drop down until before I apply a jquery method to the selection drop down.
In my previous related question I was able to populate the drop down successfully using the following code.
<select name="shippingState" id="shippingState" ng-model="accountAddresses.shippingState" ng-options ="state.abbreviation for state in states track by state.abbreviation" class="state form-control" size="1">
</select>
Now I want to apply the jquery method (a custom selectbox dropdown styling library).
When data loads, I am able to apply the method manually in the browser console. The problem is I can only do the action in the browser console manually.
When the drop down data is fetching I can not run the same method in angular.
Question: How do I can trigger an action when data binding finishes in Angular?
EDIT - I created a directive and modified my html to trigger the directive.
Still I do not get a custom styled element.
Directive Chained to the Root Controller
directive('onDataBind', function (id) {
alert(id);
function link(elem, id) {
elem.ready(function(id){
$scope.CreateDropDown(id);
});
}
})
HTML Modified
<select name="billingState" id="billingState" ng-model="accountAddresses.billingState" ng-options ="state.abbreviation for state in states track by state.abbreviation" on-data-bind="CreateDropDown('billingState')" class="state form-control" size="1">
</select>
Create Drop Down at the Scope Level
$scope.CreateDropDown = function(id){
$("#"+id).selectbox();
//selectbox is the following library - https://github.com/olivM/jQuery-Selectbox
}