angular-input
Angular input
2023-09-11 14:17:26 时间
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <script src="http://localhost:81/js/jquery.js"> </script> <script src="http://localhost:81/js/angular.min.js"> </script> <body ng-app="Demo"> <div ng-controller="TestCtrl"> <input type="text" ng-model="a" test /> <button ng-click="show(a)">查看</button> </div> </body> <script> var app = angular.module('Demo', [], angular.noop); app.directive('test', function(){
//input 指令的 link有第四个参数,$ctrl有些方法,你可以自己拿来用 var link = function($scope, $element, $attrs, $ctrl){ console.log( $ctrl ) $ctrl.$formatters.push(function(value){ return value.join(','); }); $ctrl.$parsers.push(function(value){ return value.split(','); }); } return {compile: function(){return link}, require: 'ngModel', restrict: 'A'} }); app.controller('TestCtrl', function($scope){ $scope.a = []; //$scope.a = [1,2,3]; $scope.show = function(v){ console.log(v); } }); </script> </html>
相关文章
- [Angular 9] Improved Dependency Injection with the new providedIn scopes 'any' and 'platform'
- [Angular] Architectures for Huge Angular Based Enterprise
- [Angular] 'providedIn' for service
- [Angular HTML] Implementing The Input Mask Cursor Navigation Functionality -- setSelectionRange
- [Angular HTML] Overwrite input value, String.fromCharCode & input.selectionStart
- [Angular] Show a loading indicator in Angular using *ngIf/else, the as keyword and the async pipe
- [Angular 2] ROUTING IN ANGULAR 2 REVISITED
- [AngularJS] angular-md-table for Angular material design
- Angular 依赖注入里factory函数的调用时机
- Angular input控件的click事件表达式如何被转换成JavaScript函数
- Angular应用从Component到Html的数据绑定是如何实现的 -数据流的讨论
- Angular Component input字段传递值的几种变式 variant
- 使用Angular可重用Component思路实现一个自带图标(icon)的input控件
- Angular input控件的click事件响应处理的调用上下文
- Angular应用的angular.json文件字段一览
- Angular里的routerLink不能按照期望工作的一个问题
- socket.io+angular.js+express.js做个聊天应用(三)