toddmotto / angular-component

Fully featured .component() polyfill for Angular v1.3+
https://toddmotto.com
Other
191 stars 30 forks source link

one-way binding not working? #43

Open linkedrank opened 7 years ago

linkedrank commented 7 years ago

Hello -

I'm trying to use this angular-component.js with angular 1.4.14 for this component: https://github.com/pablojim/highcharts-ng

Its scope is two one-way bound variables. If you see the code below, when run, the variable config is just not defined in the controller when it goes to add the method getChartObj. In addition, the modifiedBindings variable in this case in your code works out to be {}. It works if I change the binding for the two variables to =.

Any ideas?

  angular.module('highcharts-ng', [])
    .component('highchart', {
        bindings: {
            config: '=',
            changeDetection: '='
            //config: '<',
            //changeDetection: '<'
          },
          controller: HighChartNGController
    });

  HighChartNGController.$inject = ['$element', '$timeout'];

  function HighChartNGController($element, $timeout) {
    var seriesId = 0;
    var ctrl = this;
    var prevConfig = {};
    var mergedConfig = {};
    var detector = ctrl.changeDetection || angular.equals;
    this.$onInit = function() {
      ctrl.config.getChartObj = function(){
toxaq commented 7 years ago

There's a pull-request for this already, #39 . Any thoughts on this @toddmotto ? This polyfill is great for us stuck in 1.4 land a little longer, thanks for creating it!