last day (15 days later) » 

5:56 PM
0
A: Set initial model value for an angular directive

deitchOh definitely set the value of the ng-model in the scope. Assuming you sometimes want it set and sometimes not, why can you not do: <input type="checkbox" class="switch" ng-model="isActive" ngTrueValue="true" ngFalseValue="false" data-initial-checked="true" ng-change="toggleVisibility...

 
Sorry, my description was wrong, I saw the template of the directive and not the directive
 
@Avraam I am a little confused. Happy to modify my answer to better address the question, if you can clarify the question a bit more?
 
I tried they way you suggested me but attrs["dataInitialChecked"] and scope.isActive are undefined. Any idea why?
 
Move it into a fiddle, show me, we will fix it. But instead of templateUrl in the directive, use template so it is inline, makes it easier in jsfiddle.
Here I started a fiddle for you jsfiddle.net/m0q28vjc/1
I will try to drop in here when I can, a bit busy today. But look at the sample fiddle I threw up for you. It works, now you can modify it to explain what you want.
 
I used your fiddle, I added another checkbox, in the second the the data-section is equal to data-section="extensions"
 
5:59 PM
So click update, and post the new URL in here.
 
I want when the data section is equal to extension the checkbox to be checked
 
I see! You have this attribute in the initial div (the one that has the directive class on it) whose name is data-section. When it is set to "extensions", you want it checked, else not?
 
exactly
 
I get it. I have 2 mins till I need to get some kids to bed, I will see if I can modify the fiddle in that time
 
thx a lot! :)
 
6:03 PM
Here you go. I am updating the answer.
 
Thank you very much!
 

last day (15 days later) »