[英]JSFiddle does not run my AngularJS code
After typing inside textarea
and clicking on a button
, I want to remove text inside textarea
using AngularJS
. 在
textarea
键入并单击button
,我想使用AngularJS
删除textarea
。 Please refer to following fiddle: 请参考以下小提琴:
http://jsfiddle.net/aman2690/2Ljrp54q/10/ http://jsfiddle.net/aman2690/2Ljrp54q/10/
Still getting 还在
Error: [$injector:modulerr] Failed to instantiate module MyApp due to:
[$injector:nomod] Module 'MyApp' is not available!
Even after setting ng-model
to ''
, textarea
does not clean up. 即使将
ng-model
设置为''
, textarea
也不会清理。
Your logic is fine. 你的逻辑很好。 Your JSFiddle isn't.
你的JSFiddle不是。 Set the framework options to
No Wrap - in <head>
. 将框架选项设置为
No Wrap - in <head>
。
need to use $scope in controller $scope acts as a model. 需要在控制器$ scope中使用$ scope作为模型。 Check the link below
检查以下链接
http://plnkr.co/edit/TpGfbDOtxvrC6FwhpbT8?p=preview http://plnkr.co/edit/TpGfbDOtxvrC6FwhpbT8?p=preview
var app = angular.module('MyApp', []); app.controller('MainCtrl', function ($scope) { $scope.message = ''; $scope.clicked = function () { console.log("here"); $scope.message = ''; }; });
将JSFiddle的代码复制并粘贴到本地HTML文件中,因为JSFiddle提供了控制台错误,代码按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.