I'm making a simple Angular Website. For Routing I'm using Angular-ui-router. When I click on Home, About the templates are not loading whereas when I click on Contact the template loads perfectly. Can someone please help me where I made a mistake.Here is the link for plunker
> https://plnkr.co/edit/8LlDl08JVbQKiD5eWEah?p=preview
You should be using templateUrl property as below code.
Your contact page was working because it is defined as a component
Updated PLUNK
you are using for contact home and about always same module 'homeModel'
the contact ist the last one and overwrites it
so use unique module for every component
also make sure you add it in your script for example
also remove backslash to get about.html
For those looking to eventually migrate to Angular 2, I had a similar problem. As an intermediated step in migrating to Angular 2 I have been trying to upgrade to Angular 1.6.1 along with the version of the ui-router that supports components. I copied your plunk, added the external library for version 1 of the ui-router and then made the changes as described in the "Guide: Route to Component", https://ui-router.github.io/guide/ng1/route-to-component . This included some syntax changes to your components and a call to the component rather than the url and template for each state. See this link for the working plunk, https://plnkr.co/edit/QsiFehbRkr7AYAYV4yiM?p=preview
In the script.js , you are using
'template'
and wrote'<home></home>'
, but you have home.html. and you want to use home.html as a template. You should usetemplateUrl: 'home.html'
insteadtemplate:'<home></home>'
Also change your code for
template: <about></about>
&template: <contact></contact>
see in the snapshot, please do change in red box in your code :
use this code in script.js and run again your code will run successfully:
See the snapshot after changing the code:
@Arjun: Your code is also correct, add some html in your template ( Like, i have done, i wrote
template: '<h1>Shubham Verma</h1>'
)(function() { 'use strict';
Please see the snapshot: