Search code examples
javascriptangularjsjsfiddle

AngularJS on JSFiddle


I'm new AngularJS, I'm trying to test the most basic form using AngularJS in JSFiddle. I'm not sure if I forget to configure anything in JSFiddle, but it is not working and it should.

I followed a basic sample from here.

I also include the CDN from here.

Here is the Angular code:

var app = angular.module('myApp', []);
app.controller('formCtrl', function($scope) {
    $scope.firstname = "John";
});

Link to my Fiddle: http://jsfiddle.net/bheng/tth4guev/


Settings

enter image description here


include

enter image description here


enter image description here

How would one go about debugging this further?


Solution

  • There are two things missing

    (i) You need to add ng-app directive as follows,

    <div ng-app="myApp" ng-controller="formCtrl">
    

    (ii) Change the angular.js script version above 1.1 to use without a global controller, and change load type as No wrap in <head>

    enter image description here

    WORKING FIDDLE