munchschair munchschair - 6 months ago 38
AngularJS Question

Why isn't my angular working correctly?

I have been running into some issues running angular on my system. I've been learning from w3 schools demos of angular that demonstrate the different components.

Here is one I am trying:

Here is the code I am using:

<!DOCTYPE html>
<script src=""></script>
<script src="//"></script>

<body ng-app="myApp">

<p><a href="#/">Main</a></p>

<a href="#banana">Banana</a>
<a href="#tomato">Tomato</a>

<p>Click on the links to change the content.</p>

<p>The HTML shown in the ng-view directive are written in the template property of the $routeProvider.when method.</p>

<div ng-view></div>

var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
    .when("/", {
        template : "<h1>Main</h1><p>Click on the links to change this content</p>"
    .when("/banana", {
        template : "<h1>Banana</h1><p>Bananas contain around 75% water.</p>"
    .when("/tomato", {
        template : "<h1>Tomato</h1><p>Tomatoes contain around 95% water.</p>"


It won't switch between the header tags on my system.

Edit: The code works fine elsewhere but not on my system.
It is in my apache folder. Running off of localhost. JavaScript, php and html work fine. I've used jQuery too. Any idea why angular may be having issues?


Your file may be cached in your browser so even saving the file is not updating what is running in your browser.

Clear your browser cache. Restart your browser.