[progress Communities] [progress Openedge Abl] Forum Post: Re: Binding Variable To Custom...

  • Thread starter Thread starter egarcia
  • Start date Start date
Status
Not open for further replies.
E

egarcia

Guest
Hello Louis, Here is a possible approach. If your component is defined in a custom section, for example, in topSection.html, you can define specify the ng-model property for the component so that it points to a property in the scope. Example: Custom HTML: {{testVariable}} IF you have defined the component via the designer (custom view using the blank view option), then you could set ng-model dynamically using the following code: function setNgModel($scope, componentName, variableName) { var cancelWatch = $scope.$watch(function() { var element = angular.element("#" + componentName); return element.length === 0 ? undefined : element; }, function(element, oldValue) { if (element) { element.attr("ng-model-options", "{ updateOn: 'default blur', debounce: { 'default': 500, 'blur': 0 }}"); element.attr("ng-model", variableName); $compile(element)($scope); cancelWatch(); } }); } This code sets ng-model and ng-model-options on the specified component. You can call the setNgModel() function from the onShow() handler. Example: setNgModel($scope, "textbox0", "testVariable"); You can then set "testVariable" in the scope dynamically. Example: onRowSelect: function(e) { var selectedRows = e.sender.select(); var dataItem = e.sender.dataItem(selectedRows[0]); this.scope.testVariable = dataItem.Name; } You could place setNgModel() in your own library so that you can reuse the code and enhance/change it when you need to. I hope this helps, Edsel

Continue reading...
 
Status
Not open for further replies.
Back
Top