0

I am using AngularJS highcharts (https://github.com/pablojim/highcharts-ng)

I have this config and I need make sure it is only binded once. I looked up one-way binding on AngularJS and it says I need to use :: if I am using AngularJs 1.3(Which I am ). But I am not sure how to use it on a custom directive.

 <highchart config="configtemp"></highchart>

I tried something like but it doesn't work

 <highchart config=":: configtemp"></highchart>
1
  • Could you further explain what exactly "it doesn't work" means. As per my comment below, using :: will indeed prevent the value of the attribute config from changing, so if the highchart directive is gathering new config data, it's not from this scope value. Commented Apr 19, 2016 at 19:45

1 Answer 1

2

In this regard custom directives work the same as angular directives. AngularJS highcharts has an isolate scope as per:

scope: {
    config: '=',
    disableDataWatch: '='
  },

So it's scope will consist of the values assigned to those attributes in the html. Thus

<highchart config=":: configtemp"></highchart>

will mean that on the directive scope scope.config will be equal to ::configtemp. Since you have the '::' the value of configtemp will not change (better known as one-time binding) from it's first value as you suggested/expected. (Example of this in plunker form).

Highcharts does have some extra logic, but ultimately it's internal config is derived from this attribute/scope value.

Without further information, I cannot advise what "doesn't work".

Sign up to request clarification or add additional context in comments.

3 Comments

I would like to use one config for multiple charts, would it work?
jsfiddle.net/u40vs8hk - yes, though the chart data comes from the series property on the config, so if you can't set this dynamically (due to one time binding) you'd end up with the same chart twice. Hope that helps.
I'm ending up with the same chart.. i dont think it would work but thanks for help tho

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.