Javascript Angular formly-在templateOptions变量上设置观察者
我想设置一个监视程序,当templateOptions中的特定值更改时,它将为该字段运行一个函数。当您想知道输入已被更改时,可以使用普通的Formy watcher,因此在我的情况下这不起作用。我已经尝试过expressionProperties,但我无法将其用于work eater 我举了一个例子。Javascript Angular formly-在templateOptions变量上设置观察者,javascript,html,angularjs,angular-formly,Javascript,Html,Angularjs,Angular Formly,我想设置一个监视程序,当templateOptions中的特定值更改时,它将为该字段运行一个函数。当您想知道输入已被更改时,可以使用普通的Formy watcher,因此在我的情况下这不起作用。我已经尝试过expressionProperties,但我无法将其用于work eater 我举了一个例子。 当您将鼠标悬停在一个字段templateOptions上时,有两个输入字段。鼠标悬停变为true,鼠标悬停时,鼠标悬停布尔值变为false。当mouseOver更改时,我能做些什么,以使函数运行?
当您将鼠标悬停在一个字段templateOptions上时,有两个输入字段。鼠标悬停变为true,鼠标悬停时,鼠标悬停布尔值变为false。当mouseOver更改时,我能做些什么,以使函数运行?如果您想为每个单独的字段设置控制器,您只需在字段上设置一个控制器,或者在指定要在ng mouseOver中运行的函数后,如果每个字段的函数相同,您可以将其放置在模板本身中。像这样:
formlyConfigProvider.setWrapper([
{
template: [
'editorEnabled: {{to.editorEnabled}}',
'<div ng-mouseover="to.editorEnabled=true; Update()" ng-mouseleave="to.editorEnabled=false; Update()">',
'<formly-transclude></formly-transclude>',
'</div>'
].join(' '),
controller: function($scope) {
$scope.Update = function() {
//Code to run when value changes
}
}
}
]);
vm.fields = [
{
key: 'textField1',
type: 'input',
templateOptions: {
label: 'Input1',
type: 'text',
value:vm.model.textField1,
editorEnabled: false
},
controller: function($scope) {
$scope.Run = function() {
alert('Changed!');
}
}
},