1

I am looking at using Angular JS to mamange my HTML builds more effectively and am trying my hand at templating some of my HTML. However, it doesn't seem to work? I have;

  <div class="container">

      <div ng-include='"templates/menu.html"'></div>
      <div class="row">
          <div class="col-xs-12">
              <h1>Hello, baby!</h1>
              <p>This is the first ever Angular JS I have ever done.</p>
          </div>
      </div>         
  </div>



<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="_includes/scripts/bootstrap.min.js"></script>
<script src="_includes/scripts/angular.js"></script>

Then I created a folder called, templates, where I have placed a HTML file, called menu, containing a navigation ul saving his obviously as menu.html. When I view index.html in my browser the menu is not rendered. Any help welcome. Thanks

0

1 Answer 1

3

Updated answer (summary of discussion below).

  • Working example in: http://jsfiddle.net/uo04c05h/
  • Angular should be started by ng-app directive <div ng-app class="container">
  • Path to files is relative to the file where angular is initiated
Sign up to request clarification or add additional context in comments.

7 Comments

Thank you for the reply. I was using this as a guide airpair.com/angularjs/building-angularjs-app-tutorial If the quote is inside the double quotes then the artcile is incorrect I guess. However, changing it in my code still didn't render anything. Any ideas? Thanks
Could you try: <div ng-include src="'templates/menu.html'"></div> - Also make sure that path is correct and is relative to where angular app is initialized. So it may be need to be for example /templates/menu.html
I now have <div ng-include src="'templates/menu.html'"></div> and the path is correct to that menu.html How do I initialize the angular app?
More research reveals that I need to install Git and Node Js and figure out from the mad scientists how to set these up before Angular will even work. What Node JS actually does is beyond me. I thought it would be made fairly straight forward. For example, link to angular.js add the ng-includes tag, put some HTML in a separate file and then open in the web Browser and boom. Obviously not. The goal would be to be abe to edit one menu.html file instead of having to edit all 300 static web pages that include the menu. Thanks for the help though, much appreciated.
nodejs is for server side, and git has nothing to do with it. One last try - Try to add the attribute in body <body ng-app> that would init angularjs.
|

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.