简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM