0

I have two controllers and I'm using the AngularJS $routeProvider to load multiple pages. When I click on the link from the first partial to go the second one, the second partial does not render, and the template tags are all that show.

So, in the first partial, this renders to Hello World:

<h1>Hello {{name}}</h1>

But, this doesn't render on the second partial:

<h1>Hello {{name}} on page 2</h1>

Here's a plunkr to show what I mean: http://plnkr.co/edit/7X2vlIhMvLlIqE4UvC09?p=preview

1
  • Might want to check your error console next time ~ "ReferenceError: $routeParams is not defined". Looks like you aren't injecting $routeParams into your controller Commented Apr 3, 2014 at 4:14

1 Answer 1

3

You are not injecting $routeParams to your controller. Inject it to your controller like:

app.controller("UserDetailCtrl", function($scope, $routeParams) {

This will solve your issue

In your controller you named the scope variable as $scope.name2 and in your partial2.html page you are binding to {{name}}. That is the problem. Change it to {{name2}} or either change your scope variable to $scope.name

Sign up to request clarification or add additional context in comments.

4 Comments

I thought this too but it doesn't appear to be working on the plnkr demo
Ya it is working for me. After doing this when clicking on user name it is rendering the partial2.html page
Never mind, OP has $scope.name2 instead of $scope.name in their controller
Yes thats the issue. I just checked it.

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.