mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 13:43:09 +00:00
[Autoflow] Add getter-setter controller
Add a utility controller for interacting with getter-setter style ngModels (similar to ng-model-options with getterSetter: true, but support for that is not present in the current version of Angular.) Specifically, this is used to support the input filter control, which in turn is used within the autoflow tabular view. WTD-614.
This commit is contained in:
parent
becc858349
commit
3251be2d1c
@ -55,6 +55,11 @@
|
||||
"key": "BottomBarController",
|
||||
"implementation": "BottomBarController.js",
|
||||
"depends": [ "indicators[]" ]
|
||||
},
|
||||
{
|
||||
"key": "GetterSetterController",
|
||||
"implementation": "GetterSetterController.js",
|
||||
"depends": [ "$scope" ]
|
||||
}
|
||||
],
|
||||
"directives": [
|
||||
|
@ -1,5 +1,13 @@
|
||||
<!-- look at action-button for example -->
|
||||
<span class="t-filter l-filter">
|
||||
<input type="search" class="t-filter-input" ng-model="filter" placeholder="Filter..."/>
|
||||
<a class="ui-symbol t-a-clear s-a-clear" ng-click="filter = null">x</a>
|
||||
<span class="t-filter l-filter"
|
||||
ng-controller="GetterSetterController">
|
||||
<input type="search"
|
||||
class="t-filter-input"
|
||||
ng-model="getterSetter.value"
|
||||
placeholder="Filter..."/>
|
||||
<a class="ui-symbol t-a-clear s-a-clear"
|
||||
ng-show="getterSetter.value !== ''"
|
||||
ng-click="getterSetter.value = ''">
|
||||
x
|
||||
</a>
|
||||
</span>
|
30
platform/commonUI/general/src/GetterSetterController.js
Normal file
30
platform/commonUI/general/src/GetterSetterController.js
Normal file
@ -0,0 +1,30 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
function GetterSetterController($scope) {
|
||||
|
||||
function updateGetterSetter() {
|
||||
if (typeof $scope.ngModel === 'function') {
|
||||
$scope.getterSetter.value = $scope.ngModel();
|
||||
}
|
||||
}
|
||||
|
||||
function updateNgModel() {
|
||||
if (typeof $scope.ngModel === 'function') {
|
||||
$scope.ngModel($scope.getterSetter.value);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$watch("ngModel()", updateGetterSetter);
|
||||
$scope.$watch("getterSetter.value", updateNgModel);
|
||||
$scope.getterSetter = {};
|
||||
}
|
||||
|
||||
return GetterSetterController;
|
||||
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user