Unable to pass data to a controller inside a component in AngularJS

41 views Asked by At

I have following component

componentsModule.component('detailComponent', {
    templateUrl: 'detailTemplate.html',
    scope: {},
    bindings: {
        textParam: '='
    },
    controller: ['$mdDialog',  function($mdDialog) {
      this.textParam // this is undefined always
   }]
});

I am loading template in a dialog from other controller like this

$scope.textParam = tParam;
const parentEl = angular.element(document.body);
$mdDialog.show({
      template: '<detail-component text-param="$scope.textParam"></detail-component>',
      ariaLabel: 'detailComponentDialog',
      parent: parentEl
}).then((savedDatails) => {});

If I use binding as @ then I get $scope.textParam as a string inside my controller in this.textParam but if I set binding as < or = then I get undefined

0

There are 0 answers