Hi Sander, Thank you very much. It does make sense. I asked my self if I should do it with a $watch instead but I actually found a way to do it with out it
http://plnkr.co/edit/HaJvsIOHjpnAVW5DFaft?p=preview I did this yesterday and got it to work. I removed the directive with the template and just put the actual HTML in the HTML file as well as removed sorta moved the hide/ show logic to the HTML. The only thing I m doing in the directive is when someone selects an option, update the *Chosen value. I may change to using a $watch but even so, since we are following best practices, I thought having watchers in your controller is not a good thing. So whether I use a watcher or the logic I currently have, I will need a directive no? Also this is not so related, why do you use what seems to be like closures/ singletons whatever its called in your apps? ie. (function() {}()); what is the advantage You can email me if you want so we can keep this stuff separated from this thread On Thursday, May 8, 2014 3:43:32 AM UTC-4, Sander Elias wrote: > > Hi Billy, > > Well, this one did "work". > Ok, it looks like you found a bug. While this needs some attention I took > a step back and looked at what you were trying to do. > Then it occurred to me you are trying to solve business logic with > directives. While possible it is not a good idea, and it will become an > maintenance nightmare. > Have a look at this: http://plnkr.co/edit/7F3nlgtxT9sx2FJ4isMF?p=preview > I moved all the logic to the controller. The view will follow the data. > The logic does not care about the html at all! > Perhaps it helps to think of the html/dom as write-only. If you ever feel > the need to read anything out of the DOM/HTML you have a code smell. > In angular apps your model/data rules, and the view/html will follow the > data. > > Does this help a bit? Does it make sense to you? > > Regards > Sander > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
