ocespedes
ocespedes

Reputation: 1293

Load service data into angular component

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

Upvotes: 0

Views: 67

Answers (1)

Antonio
Antonio

Reputation: 901

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

Upvotes: 2

Related Questions