谁能告诉我为什么这个简单的angularjs jsfiddle无法正常工作?

时间:2021-07-07 01:35:38

Can someone tell me why this simple angularjs jsfiddle not working?

谁能告诉我为什么这个简单的angularjs jsfiddle无法正常工作?

var myApp = angular.module('myApp',[]);

myApp.controller('MyCtrl', ['$scope', function MyCtrl($scope) {
    $scope.name = 'Superhero';
}]);

and

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

    Hello, {{name}}!

</div>

results in

结果是

Hello, {{name}}!

您好,{{name}}!

https://jsfiddle.net/cbdrow8u/1/

https://jsfiddle.net/cbdrow8u/1/

2 个解决方案

#1


1  

  1. Remove ng-app="myApp" from the div tag.
  2. 从div标签中删除ng-app =“myApp”。
  3. Click the gear icon in the top right corner of HTML and in the BODY TAG field enter <body ng-app="myApp">.
  4. 单击HTML右上角的齿轮图标,然后在BODY TAG字段中输入。
  5. Click the gear icon in the top right corner of JavaScript and in the LOAD TYPE select No wrap - in <body>
  6. 单击JavaScript右上角的齿轮图标,然后在LOAD TYPE中选择No wrap-in
  7. Click Update then Run.
  8. 单击更新然后运行。
  9. Profit!
  10. 利润!

#2


4  

Click on JAVASCRIPT settings in the code panel and change LOAD TYPE from OnLoad to NoWrap in body.

单击代码面板中的JAVASCRIPT设置,将LOAD TYPE从OnLoad更改为正文中的NoWrap。

#1


1  

  1. Remove ng-app="myApp" from the div tag.
  2. 从div标签中删除ng-app =“myApp”。
  3. Click the gear icon in the top right corner of HTML and in the BODY TAG field enter <body ng-app="myApp">.
  4. 单击HTML右上角的齿轮图标,然后在BODY TAG字段中输入。
  5. Click the gear icon in the top right corner of JavaScript and in the LOAD TYPE select No wrap - in <body>
  6. 单击JavaScript右上角的齿轮图标,然后在LOAD TYPE中选择No wrap-in
  7. Click Update then Run.
  8. 单击更新然后运行。
  9. Profit!
  10. 利润!

#2


4  

Click on JAVASCRIPT settings in the code panel and change LOAD TYPE from OnLoad to NoWrap in body.

单击代码面板中的JAVASCRIPT设置,将LOAD TYPE从OnLoad更改为正文中的NoWrap。