Home > Web Front-end > JS Tutorial > Sharing of input examples in angularJS_AngularJS

Sharing of input examples in angularJS_AngularJS

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:15:03
Original
994 people have browsed it

Here is an example of how to use the input command

Copy code The code is as follows:





Untitled Document









<script><br> var app = angular.module('Demo', [], angular.noop);<br> ​ app.directive('test', function(){<br> //The link of the input command has a fourth parameter, $ctrl has some methods, you can use it yourself<br> var link = function($scope, $element, $attrs, $ctrl){<br> console.log( $ctrl )<br> $ctrl.$formatters.push(function(value){<br>             return value.join(',');<br> });<br> $ctrl.$parsers.push(function(value){<br>             return value.split(',');<br> });<br> }<br> Return {compile: function(){return link},<br>                require: 'ngModel',<br>               restrict: 'A'}<br> });<br> app.controller('TestCtrl', function($scope){<br> $scope.a = [];<br> //$scope.a = [1,2,3];<br> $scope.show = function(v){<br> console.log(v);<br> }<br> });<br> </script>

The code is very simple, friends can expand it freely, I hope you can like it

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
angular.js - angularJS ng-style用法
From 1970-01-01 08:00:00
0
0
0
angular.js - AngularJS form validation
From 1970-01-01 08:00:00
0
0
0
angular.js - Learning AngularJS
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template