0

iam working on angulatjs uirouter.The code contains 2 states say home and new and when i click on any of these links the state & url changess.But the problem is the template corresponding to those state is not loading.

here is my code

var app=angular.module("myApp",['restangular','ui.router']);
app.config(['RestangularProvider',function(RestangularProvider){
    RestangularProvider.setBaseUrl('http://localhost:9999')
}])
app.config(['$stateProvider',function($stateProvider){
   $stateProvider.
      state('home',{
          url:'/home',
          templateUrl:'/view/home.html'
      })
      .state('next',{
          url:'new',
          templateUrl:'/view/new.html'
      })
}])

html

<a ui-sref='home'>
    home
</a>
<a ui-sref='next'>
    new
</a>

i don't know what the problem is? can anyone help me?..

2
  • Is there an error appearing on console? Maybe the template files are not referenced properly, or not served properly by your local server. Commented Feb 16, 2015 at 7:50
  • there are no error on console. when i remove the template file from the /view location it shows an error like GET localhost:9999/view/new.html 404 (Not Found) Commented Feb 16, 2015 at 7:52

1 Answer 1

0

It seems that you missed the ui-view in order to let the template get plugged in

<a ui-sref='home'>
  home
</a>
<a ui-sref='next'>
  new
</a>
<div ui-view></div>
Sign up to request clarification or add additional context in comments.

2 Comments

Now the new template is loding below the old contents. Is there any way to load new template by replacing the old one?
If you'll start your application containing a default template, and you'll put those ui-sref links inside this default template, the default/'old' content will be changed when you navigate between the states.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.