0

I don't know how to "include" partials on templates. For example, I've an template "index". When the user navigate to "/" I like re render some divs on "index" from partials (login box and some others text div), when de user navigate to "/newAccount" I like re render same divs on "index" but with others partials.

The question is, it's the correcly way to use of AngularJS? Similar to the includes on Facelets?

Thanks! ;)

Here a pseudo code of my idea:

Template:

<html>
  <body>....{include:mainBox}....{include:foot}...</body>
</html>

Partials for /newAccount:

{define mainBox}

<div>New user</div>
<div>Username:<input/></div>

{define foot}

<div>...</div>

Update:

Some like this is wrong?

function IndexCtrl($scope) {
    $scope.mainPage = 'partials/index/loginbox.html',
    $scope.footPage = 'partials/index/footer.html',
}

After in the template I put:

<div ng-include="mainPage"></div>
...
<div ng-include="footPage"></div>

And the route:

when('/', {
       templateUrl: 'partials/index/layout.html',
       controller: IndexCtrl
   }) 
1
  • It's good, if the template url will never change you can put the url as string in the ng-include without creating variables in the $scope Commented Jul 4, 2012 at 17:22

1 Answer 1

1

Use ng-include for this. Maybe what you want is ng-view + $routeProvider

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

Comments

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.