But when it gets more complicated I use other methods as I described. I overstress your argument, but it includes also all kind of data database, etc. Also faced with the need to replace the template in the current components from external data sources. My requirement is not exotic and needed by many people out there. Lets say, instead of html, my template file is app.
I have been trying to do a similar thing where I generated input controls for forms. This is a totally legitimate approach. This next bit of code is for fetching the data and populating a content property that we are going to bind to in a template in just a moment. Also, it is also worth mentioning that I will sometimes use this technique to compile a directive a runtime so I can test it. Also, what happens if you need to dynamically compose the template on the fly based on business logic? And with WebPack, the Angular Cli defaults to using the component-relative path approach described here.
As it is available in Angular 1 Please don't be dogmatic on this issue and consider supporting real world requirements in Angular 2 Thanks : I know you don't want to provide this feature. And this is a problem in reality if you apply that principe in a large scope. Another question is the priority of such functionality in timeline and the standpoint of Angular core team. The articles I have read so far are all helpful. Then, do you think it would be feasible to store the templates in separate files and retrieve only the one we need? The vision is given, that's for sure. And some pragmatism could also be a win for angular 2.
I have a question which I would be grateful if you can help me out on. Thanks to Soós Gábor for his WebPack expertise and insight here. Even worse, what happens if you the criteria for choosing the template is not a simple boolean value but based on multiple conditions? I recently did something similar to distinguish between text, photo, and event posts. Please, don't be dogmatic and rethink your approach. In general for an application level component I would stick with defining separate components as others have mentioned. You said: If you have an example on how to encapsulate e.
But our markup remains clean and uncluttered. I have created a small sample I would really appreciate if some one could throw some insight on what exactly the issue is. Really amazed on how elegant and simple you made your solution to what seems like a complex problem. Why Component-Relative Paths are not supported At first this limitation seems like a real feature screw-up within Angular. As a result I needed to be able to style each content item according to its content type. But consequently you have to remove the compiler from angular 2 then, because in principle I can already achieve what I want to do. It's just my opinion that they get hard to work with when you have a lot of them.
I am not advocating using this approach for everything but it is definitely more extensible and allows you to exert more granular control over your view without suffering a huge performance hit during the digest cycles. You can swap between multiple templates defined with a structural directive inside the same html file. If not, I'm letting the original method takes charge of the request and compile phase. I tried several method but none of them worked. So, it would sort of be like a single page application where a certain content container uses one stylesheet and one component. Component had to be created and compiled at runtime to enable the bindings in the templates. In that case, when the main.
But, I don't know much about Angular and I could be going about this the wrong way. Back to our discussion, what is needed - in my opinion - is good mix of pragmatism and architectural vision. They work fine but imo are more the realm of component libraries. Which is not practicable and increases the danger of recoding all after the next angular release Expected behavior Provide a way of loading a template dynamically for a component. One of the input properties on Component C is Property A. But just wanted to share another way of going about changing views on the fly. I had a task where I needed to render arbitraty templates supplied from the server to display a custom form.
Conclusion The key lesson is to set the moduleId : module. I just feel like making each of these as singular components would be overkill and potentially be repeating code. It is clear now what you mean. I am just learning Angularjs, and how to use templateUrl to load a template. I can imagine that type of simplification and having so high level of functionality. For example this can be done in Chrome like so: You can also use the expressjs web server to load your index. Upon submission, your post's header will have the 'flair' option listed with the other options.
I can't see from the ng-descendant proposal it will be a solution for my request. Without the moduleId setting, Angular will look for our files in paths relative to the application root. Meaning that in for example for the variable imageTemplate we store a string that is the templateUrl of that template, instead of the template itself. Separate layer means one front-end application which is created on backbone,angularjs etc and other one back-end application, which is created on server-side languages like php,java,. Unless the layout for each question is varying wildly then doing a file for each question is way more work than is necessary. How do I link the scope so the objects I pass into my custom directive can be retrieved after they are edited? I'd appreciate if you would also give these kind of requirements some valuation.