I'm following along an online tutorial, and attempting to get angularjs to work on jsfiddle . i'm not very familiar with jsfiddle and am having a hard time getting the javascript and html to work together due to (i think) the jsfiddle settings.
here's my code: http://jsfiddle.net/russellelbert/yh4c1hoe/
HTML:
<h1>{{"hiking..."}}</h1>
<div ng-controller="HikeController as hike">
<h1> {{hike.trail.name}} </h1>
<h1> {{hike.trail.miles}} </h1>
<h1> {{"keep going"}} </h1>
</div>
<h1>{{"done"}}</h1>
JavaScript :
(function(){
var app = angular.module('rew', []);
app.controller('HikeController', function(){
this.trail = hike;
});
var hike = {
name: 'Colchuck Lake',
miles: 4.5,
}
})();
i have the framework and extensions set to:
and the fiddle options set to:
but only the first H1 seems to be working. output is such:
hiking... {{hike.trail.name}} {{hike.trail.miles}} {{"keep going"}} {{"done"}}
can anyone see what i am doing wrong? i'd like to keep the structure of the javascript as similar as it is to the code shown so i can follow along with the tutorial - my assumption is that something is wrong in the jsfiddle settings.
thanks for your help!
You were using old version of angular. Updated the version. Everything else was fine.
http://jsfiddle.net/yh4c1hoe/1/
No Code changes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.