Model rejection in the absence of input

I understand you can put debounce anywhere or with ng model. But what if there are several ng-models of the same object and one place to "display". And I want to set debounce on the "display" element.

For example, how to do it name

to display slowly in <p>

, but sync quickly between input

:

http://plnkr.co/edit/RZfqDfNGVdswniuPkuIC?p=preview

Html

<!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <meta charset="utf-8" />
    <title>AngularJS Plunker</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <link rel="stylesheet" href="style.css" />
    <script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.1/angular.js" data-semver="1.4.1"></script>
    <script src="app.js"></script>
  </head>

  <body ng-controller="MainCtrl">
    <p ng-model-options="{ debounce: { 'default': 500 } }">Hello {{name}}!</p>
    <input ng-model="name" >
    <input ng-model="name">
  </body>

</html>

      

Js

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.name = 'World';
});

      

+3


source to share





All Articles