0

I'm new to AngularJS. In our project, we're forced to create our web app(multi-pages) in angularJS, though we know AngularJS is only for SPA. At the moment I've a homepage, which is created in AngularJS and all other connected pages are in jQuery.

I've created a navBar in the Homepage, which needs to show up on all other pages as well. But at the moment the navBAr data is not showing up in the other pages. How could I do that? How do I reuse my navCtrl in all the pages?

Please note that footer is still in jQuery, and will have to do the same with that as well. This is how my homepage looks as of now:

<body ng-app="App">
    <nav ng-controller="navCtrl"></nav>
    <main ng-controller="mainCtrl"></main>
    <footer></footer>
</body>
Difster
  • 3,264
  • 2
  • 22
  • 32
Sunny
  • 902
  • 3
  • 18
  • 41
  • What is ng-ctrl? Shouldn't it be ng-controller? – Vivz Aug 07 '17 at 07:10
  • yup, sorry I meant the same. – Sunny Aug 07 '17 at 07:13
  • What's your question? AngularJS is not only for SPA (although it is cleaner to write this way), multi-page is fine as well. – Icycool Aug 07 '17 at 07:13
  • Where have you defined navCtrl in your application? I mean have you defined it in your mainjs so that it will be avialable globally? – Vivz Aug 07 '17 at 07:14
  • In 'nav.html'... – Sunny Aug 07 '17 at 07:15
  • no it is in a seperate file...it's outside my homepage.js..but it gets loaded in the homepage...not in the other files as it used to get loaded earlier.. – Sunny Aug 07 '17 at 07:17
  • 1
    You can use routing for this so that you have to define your `HomePage` as a parent state and other pages are child one. if you define in this way you can add separate controllers for different different pages that time you can access parent data so no need to call the same controller again & again – ojus kulkarni Aug 07 '17 at 07:20
  • How do I do that? – Sunny Aug 07 '17 at 07:22
  • my NavBar is also using ajax to get the data.. – Sunny Aug 07 '17 at 07:34
  • If you don't want to try angular routing, then you can choose this way: –  Aug 07 '17 at 09:01
  • Why don't you try this way?

    –  Aug 07 '17 at 09:13

0 Answers0