javascript - angular tutorial not working on fiddle -
i've been reading angularjs tutorials on tutorialspoint.com , i've been testing things learn on jsfiddle. first few things tried worked, ng-model
, ng-bind
. empty ng-app
(ng-app=""
).
however, i'm trying make app , controller, not working. heres fiddle
how fix code? i've done tutorial says. noticed when inspecting page following error:
error: [$injector:modulerr] failed instantiate module myapp due to: [$injector:nomod] module 'myapp' not available! either misspelled module name or forgot load it. if registering module ensure specify dependencies second argument.
<div ng-app="myapp" ng-controller="appcontroller"> <div> <span>first</span> <input type='text' ng-model="person.firstname"/> <span ng-bind="person.firstname"></span> </div> <div> <span>last</span> <input type='text' ng-model="person.lastname"/> <span ng-bind="person.lastname"></span> </div> <div> {{ person.fullname() }} </div> </div> var myapp = angular.module("myapp", []); myapp.controller('appcontroller', function($scope) { $scope.person = { firstname: "one", lastname: "two", fullname: function() { var personobject; personobject = $scope.person; return personobject.firstname + " " + personobject.lastname; } }; });
under frameworks , settings change thing says onload no wrap - in <head>
or no wrap - in <body>
Comments
Post a Comment