ocespedes ocespedes - 1 year ago 111
Javascript Question

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download