Conditional add html attributes to element in directive template. AngularJS Conditional add html attributes to element in directive template: Josh David Miller. Plan to move the template string to an external template once I get the base functionality working and plan on looking into breaking this up into multi directives. Embedding interpolation markup inside expressions Note: AngularJS directive attributes take either expressions or interpolation markup with embedded expressions. It is considered bad practice to embed interpolation markup inside an expression.
Bernardo Castilho 17-Jun-Jun-13 13:27Hi DannyThanks for the article, great job.About your comment:I found out the hard way (and through some googling) that a timeout is required here in order to prevent an error in angular. Something about the digest already being in progress or something like that. I don't remember the specifics or pretend to understand exactly why we get the error.I believe the problem is that you are not supposed to call scope.$apply while Angular is already applying changes.
The easy way to fix this is to check the scope.$$phase variable and call $apply only if that is null. This works for me:if (!scope.$$phase) scope.$apply(.);Seems to me Angular could perform that check itself, but I guess they must have reasons not to.Thanks again for the article. Mikhail-T 16-Jan-13 9:0716-Jan-13 9:07Danny,Your article definitely helped me with my project (I just started learning AngularJS), thank you for sharing!I haven't rated it yet though, as there is a bit of room for improvement, mainly by adding a source code. I've read other comments and saw that you have a problem uploading source files, so consider other alternatives (perhaps better ones):1) Create working samples in the likes of or , and adding links to this article.2) Add html samples directly to this article.3) Share source files on (my refferal link, gives 500MB extra to new members) and share link here.4) Create a project on and let us fork it.I think that would be really help your readers.Regards,Mikhail.
DannyStaten 25-Sep-12 8:2325-Sep-12 8:23Sorry for all those who read the article without the example project posted. I miss-understood the UI and thought the files were uploaded when they showed up on a list next to my article the first time.
I didn't realize that there was an upload files button below that list of files that I had to click to actually get the files tied to the article. So anyway, the files are there, so the article now is a lot more useful. Sorry about the delay on that.
Hopefully some of the viewers who first saw the article will come back and find the example project helpful. Pete Appleton 25-Sep-12 0:2825-Sep-12 0:28Thanks for your article. We've recently adopted AngularJS and are very impressed with it though as you say there's a bit of a lack of documentation so it's nice to see some more information being produced.
A couple of comments, which are hopefully constructive:- I'm moderately familiar with Angular and so I have the background knowledge needed to understand the article and get value from it. Thanks for the feedback. I debated about spending more time explaining angular to start the article out, but opted not to for the sake of time among other things. Truth be told, I have been experimenting with Angular for less than a week, and found it a very natural fit with a lot of background in databinding with WPF. So it feels intuitive, but I didn't know if I could fully articulate Angular's philosophy well.I also tried to refer to the attributes you create both as directives and attributes interchangeably.
I do appreciate your feedback and I think I will try to get some time to update and improve the article on both of those points tonight. Thanks.Last Visit: 16-Sep-19 9:34 Last Update: 16-Sep-19 9:341General News Suggestion Question Bug Answer Joke Praise Rant AdminUse Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.