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