0

I have a component which takes care of drawing two lists, but in the component there is no data so nothing is drawn.

myController

function loadAllData() {
                Admin.getAllSettings()
                .then(function (settings) {
                    $scope.settings = settings.data;
                })
            }

myComponent

{
        bindings: {
            selectedData: '=',
            availableData: '<'
        },
        templateUrl: 'global/twoListSelector.directive.html',
        controller: function () {
            var me = this;

            console.log(me);
        }
    }

myView

<two-side-selector selectedData="doctorProperties" availableData="settings"></two-side-selector>

In the console.log the output for me.settings is undefined. Shouldn't the digest cycle update the setting property so it gets to the component? The service is returning data correctly but it is not getting to the component

I am using angular 1.5.9

4
  • Where do you call the loadAllData() function on your scope? It's normal that there is no data if you don't call the data function on the myComponent scope. Commented Feb 7, 2017 at 15:04
  • The loadAllData is called in a parent controller lets say controller 'A', the controller A is in the scope of my view, so that availableData="settings" should refer to the data returned by service Commented Feb 7, 2017 at 15:08
  • did you try to add console.log($scope.settings) in your promise success handler, does it print some datas ? Commented Feb 7, 2017 at 15:08
  • It does print data, but my error was what @Antonio suggested. Thanks for the reply Commented Feb 7, 2017 at 15:12

1 Answer 1

2

Try to use selected-data and available-data attributes at markup:

<two-side-selector selected-data="doctorProperties" available-data="settings"></two-side-selector>

AngularJS convert dash-separated attributes to camel-case by itself

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

1 Comment

It works! Forgot about that I thought it was only for directive names

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.