Question on $scope.$on in widget

ShAn21
Tera Guru

Hi Team,

I have one question regarding $scope.$on question in widgets.

I see the function $scope.$on("field.change", function(evt, parms) { ... } is called only when the record picker is changed within the same widget.

Is it possible to invoke this function for other fields?

If not how can we trigger similar functionality for other fields?

Thanks

1 ACCEPTED SOLUTION

I think in this case it wont work  for text field

If you want to get the changes on text field  or the value entered in the text field use ng-change directive in html code in input tag  which is already there in your code and catch it in client side using ng-change function like below

 <input type="text" ng-model='c.data.desc' id="description" class="form-control" ng-change="checkdescVal(c.data.desc)" required/>  

// this is your text code

Write below code in your client controller

client controller:

$scope.checkdescVal = function(desc) // catch the parameter which contains changed text 

{

alert(desc);

}

please try this and let me know

 

View solution in original post

7 REPLIES 7

I think in this case it wont work  for text field

If you want to get the changes on text field  or the value entered in the text field use ng-change directive in html code in input tag  which is already there in your code and catch it in client side using ng-change function like below

 <input type="text" ng-model='c.data.desc' id="description" class="form-control" ng-change="checkdescVal(c.data.desc)" required/>  

// this is your text code

Write below code in your client controller

client controller:

$scope.checkdescVal = function(desc) // catch the parameter which contains changed text 

{

alert(desc);

}

please try this and let me know

 

Hi Mohit

Thanks for confirming that the $scope.$on does not work for text field.

I was able to achieve it by calling the client side.

Regards

Hi Mohith,

I have written a custom widget that creates a bar chart. I am using angular-chartjs libraries. Although the bar chart renders fine, I am not able to fetch the chart instance. The code from the documentation in the following link and what I am trying in the widget controller is as follows:

$scope.$on('chart-create', function (evt, chart) {
  console.log(chart);
});

 

https://github.com/jtblin/angular-chart.js 

No compile error but not able to see the chart-create event being called.

Can you suggest whats wrong here.