我试图在每次聚焦时将输入大小从20改为100.然后,当它是ng-blur时,它应该从100转换为20.这是我的html代码:
<div ng-controller="MenuCtrl" class="navbar-collapse collapse bs-navbar-collapse navbar-ex1-collapse">
<input type="text" class="form-control" ng-blur="{[{ change_text_width() }]}" ng-focus="{[{ change_text_width() }]}" size="{[{search_text_width}]}" placeholder="Search">
</div>
Run Code Online (Sandbox Code Playgroud)
在我的角度模块之前,我放了一个父模块:
var JobMaps = angular.module('JobMaps', ['MenuCtrl']);
Run Code Online (Sandbox Code Playgroud)
这是我的角度代码:
var MenuCtrl = angular.module('MenuCtrl',[]);
MenuCtrl.controller = angular.module('MenuCtrl',function($scope) {
$scope.search_text_width = 20;
$scope.change_text_width = function() {
if ($scope.search_text_width==20) {
$scope.search_text_width = 100;
//alert($scope.search_text_width);
} else {
$scope.search_text_width = 20;
//alert($scope.search_text_width);
}
}
});
Run Code Online (Sandbox Code Playgroud)
观察:
| 归档时间: |
|
| 查看次数: |
2348 次 |
| 最近记录: |