AngularJs: Not able to clear input field after form sumbit -
Below is my angle code: I have not been able to empty the input after submitting the form.
Here I am able to successfully add the record but after adding the record I am trying to clear the input field but I am not able to do this.
HTML code: & lt; Body NG-Ape = "Task Dome" NG-Controller = "Task Controller" & gt; & Lt; Div class = "widget-body" & gt; & Lt; Form class = "add-task" ng-if = "addNewClicked" ng-init = "addNewClicked = false;" & Gt; & Lt; Div class = "" & gt; & Lt; Div class = "input-group" & gt; & Lt; Input name = "comment" ng-model = "input comment" type = "text" class = "form-control" & gt; & Lt; Div class = "input-group-btn" & gt; & Lt; Button ng-click = "adapter (input comment)" type = "submit" class = "btn btn-default" & gt; & Lt; I class = "glyphicon glyphine-plus" & gt; & Lt; / I & gt; & Amp; Nbsp; Add new task & lt; / Button & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; / Div & gt; & Lt; / Body & gt; JS code: & lt; Script type = "text / javascript" src = "js / angel.mmjs" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; App = angular Module ('work dmo', []); App.controller ('taskController', function ($ radius, $ http) {$ scope.addTask = function (function) {$ http.post ("ajax / addTask.php? Function =" + work). Sieve (function ( $ Response) {getTaskList ();}); $ scope.input Comment = '';}}}
Read about Prototype inheritance here:
Change this yr controller:
app.controller ('taskcontroller', function ($ Scope, $ http) {$ scope.inputComment = {value: ''}; $ scope.addTask = function (function) {$ http.post ("ajax / addTask.php? Action =" + work). (Function ($ response) {getTaskList ();}); $ scope.inputC Omment = {value: '}};}}} and replace it with the Inside yr HTML page
& lt; input name = "comment" ng - Model = "input comment" type = "text" class = "form-control">
& lt; input name = " Comment "ng-model =" input comment.value "type =" text "class =" form-control "& gt;
Comments
Post a Comment