[英]Attempt to get AngularJS to work in JSFiddle
I'm following along an online tutorial, and attempting to get angularjs to work on jsfiddle . 我正在关注在线教程,并尝试使angularjs在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.
我对jsfiddle不太熟悉,由于(我认为)jsfiddle设置,很难使javascript和html一起工作。
here's my code: http://jsfiddle.net/russellelbert/yh4c1hoe/ 这是我的代码: http : //jsfiddle.net/russellelbert/yh4c1hoe/
HTML: 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 : 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. 但似乎只有第一个H1在起作用。 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.
我想使javascript的结构与所显示的代码相似,以便我可以随教程一起进行-我的假设是jsfiddle设置有问题。
thanks for your help! 谢谢你的帮助!
You were using old version of angular. 您使用的是旧版本的angular。 Updated the version.
更新了版本。 Everything else was fine.
其他一切都很好。
http://jsfiddle.net/yh4c1hoe/1/ http://jsfiddle.net/yh4c1hoe/1/
No Code changes.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.