简体   繁体   中英

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 . Please refer to following fiddle:

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.

Your logic is fine. Your JSFiddle isn't. Set the framework options to No Wrap - in <head> .

You need to change your plunker No wrap - in <body> and add <body ng-app="MyApp"> to Fiddle Options .

Here is an example: jsfiddle

need to use $scope in controller $scope acts as a model. Check the link below

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提供了控制台错误,代码按预期工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM