last day (14 days later) » 

1:51 PM
2
Q: angularjs ui-select trouble with creating custom directive

NicolloGood day! I need to create directive with ui-select inside. Here is directive's controller and template: app.controller("servicesCtrl", ["$resource", '$scope', function($resource, $scope){ $scope.clinicServices = []; console.log($scope.data); var Services = $resource(window.b...

 
can I know why you used controllerAs: "services" as you are not dealing with this inside your controller?
 
I tried to use "this" instead of $scope inside the controller, and use this: ng-model="services.data"
 
so what was the result..console.log($scope.data) does print anything? I think remove controllerAs should work for you
 
No, it doesn't matter i think. I have just remove it, and there is no effect.
It works when I remove initialization: $scope.clinicServices = []; but there are an errors in console, and refresh doesn't work at all.
 
Do you have an error in console when it first loads?
 
1:51 PM
@Nicollo that means you are initializing servicesCtrl controller twice..
 
No, I haven't. And console.log($scope.data) printing an array of objects. I have printed {{data}} in template also.
 
Try to remove the controllerAs and the isolated scope, they might be interfering with each other. (the isolated scope and the controller scope)
 
@Omri Aharon I removed controllerAs and have no effect.
 
@Nicollo Did you remember to remove the isolated scope too ?
 
@Nicollo could you check how many times console.log($scope.data); is getting print?
 
1:51 PM
@Omri Aharon I'm sorry, but I can't understand what is isolated scope. Is it this: scope: { data: "=ngModel" }, ?
@pankajparkar every time then I call the form in modal window.
 
@OmriAharon if he remove isolated scope..then directive will not be work as reusable component..what you say?
@Nicollo then you have already initialize servicesCtrl on somewhere in parent element of your directive..
 
@pankajparkar there are 2 places where I use <services> directive. 1: when page loads there is a form to create an record, and form to edit it. first initialize creating form, and then editing form on request
 
@Nicollo if you are using controller only for directive then it make sense..I'm asking that other than directive, have you use servicesCtrl anywhere?
 
@pankajparkar No, I don't. I created it only for this directive.
 
@Nicollo Yes that is what I meant, remove the scope: { .. } just to see if this solves it at the moment.
 
1:51 PM
@Nicollo could you reproduce this issue with plunkr..so that we could help you.:)
 
@pankajparkar plnkr.co/edit/rSce8PIeaYqIwtvqXxMC?p=preview - It works here
 
@Nicollo there must be something else which is causing you an issue..
 
@pankajparka I did it! There where errors in my version of ui-select library!
 
2:13 PM
cool
so do you need anything else?
 
No, all ok now
Thanks a lot
 
Your welcome dude..
please add the asnwer so that it will help others
 

last day (14 days later) »