Simple AngularJS running on JSFiddle

后端 未结 7 895
北海茫月
北海茫月 2020-11-27 16:55

How do I make a jsfiddle out of the following code:





    
相关标签:
7条回答
  • 2020-11-27 17:58

    I am writing my answer for those who land on this page , I was used to use ng-module directive but in jsfiddle after half an hour I realized that ng-module is not allowed and you see no error , and when changed that ng-module to ng-app fiddle worked very well .I just wanted to share this .And no wrap (body) is required too.

    <div ng-app="appX" ng-controller="appCtrl">
      <p>{{greeting}}
      </p>
    </div>
    

    var app=angular.module("appX",[]);
    console.log(app);
    app.controller("appCtrl",function($scope){
    $scope.greeting="Hello World";
    });
    

    https://jsfiddle.net/cloudnine/trgrjwf1/7/

    0 讨论(0)
提交回复
热议问题