Angelos Chalaris Angelos Chalaris - 3 months ago 28
AngularJS Question

AngularJS Boilerplate works on Codepen but on on JSFiddle

I was trying to write a simple Angular app, when I came upon a problem. My perfectly simple and short boilerplate code runs entirely fine in a Codepen, but it fails to work in a JSFiddle. The snippet I created below works fine as well, but I cannot figure out why it does not work in JSFiddle. Could anyone point out what the problem is?

Codepen link: http://codepen.io/chalarangelo/pen/YWdvBV

JSFiddle link: https://jsfiddle.net/chalarangelo/1d12hm5f/1/

Code snippet:



var app = angular.module('myApp', []);
app.controller('myController', [
'$scope',
function($scope) {
$scope.demoText = 'AngularJS: This is some demo text!';
}
]);

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
<div ng-app="myApp">
<div ng-controller="myController">
<p>
{{ demoText }}
</p>
</div>
</div>




Lex Lex
Answer

You should click the JAVASCRIPT button and select an Angular version under the FRAMEWORKS & EXTENSIONS dropdown, instead of including it as an external resource.

Javascript options in JSFiddle

To fix your problem, you must select the LOAD TYPE as No wrap - in <head>.

Comments