javascript - $scope.$watch ... make it return a function on another scope? -


i have watch function returns value 2 series of data in highcharts. example below shows how work within controller:

$scope.$watch("trendcompany",function(){    return $scope.chartconfig.series[0].data =              [-1.95,0.99,9.29,4.49,-1.50,-4.05,-7.05,10.13,-19.95,             2.99,-14.55,-6.15,-20.25,-27.00,-26.10,-10.95,-10.95,5.30,             6.06,11.12,10.13,11.96,22.13,6.74,4.67,1.43,0.27,4.20,-3.45,             2.10,-1.65,1.92,1.85,0.00,1.97,-5.25,-3.30,1.67,3.87,6.27,1.89,             2.27,0.59,-1.20,-5.85,-6.60,-2.25,-2.40,-2.85,-3.45,-0.15,2.63],    $scope.chartconfig.series[1].data =              [1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2]; });  $scope.chartconfig = {     options: {         chart: {             type: 'line'         }     },     series: [{         data: []     },{         data: []     }],     title: {         text: 'hello'     },      loading: false } 

my question is.. how $scope.chartconfig.series[i].data equal function rather static array? have function returns result of data so:

//let propertyexpr string define traversal route object $scope.dataresult = function(obj, propertyexpr) {   return $parse(propertyexpr)(obj); } 

my first attempt go watch function , do...

$scope.chartconfig.series[i].data = dataresult(obj, property); 

then, tried...

$scope.chartconfig.series[i].data = function(){ return dataresult(obj,property); } 

however, neither of these working. how can make value of series scope equal invoked function?

if define function on scope have call that.

$scope.chartconfig.series[0].data = $scope.dataresult($scope.obj, $scope.property); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -