javascript - AngularJS Update input with two models with onSubmit -
i want have following.
directive 1 -> displays in users form directive 2 -> updates when user presses submit button.
examplesnippet:
<h2>{{directive1}}</h2> <!-- seen user when changes directive 1 !--> <input type="text" class="form-control" ng-model="directive1" name="input" placeholder="this primary input (this needs updated when form used user. "> <h3>{{directive2}}</h3> <!-- should changed when user presses submit button on form ng-model-options: {onupdate: 'submit'}
here modified example. directive1
updates on user input. directive2
updates on enter. jsfiddle
var app = angular.module("myapp", []); app.controller("myctrl", function($scope) { $scope.directive1 = "stackoverflow"; $scope.directive2 = "submit text"; $scope.myfunc = function () { $scope.directive2 = $scope.directive1; } });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myapp" ng-controller="myctrl"> <h2>{{directive1}}</h2> <form ng-submit="myfunc()"> <input type="text" class="form-control" ng-model="directive1" name="input" placeholder=""> </form> <h3>{{directive2}}</h3> </div>
Comments
Post a Comment