Sangeetha.V
Sangeetha.V

Reputation: 115

Unable to get value from scope using directive

<check_address address-id='address.addressId'></check_address> // html

app.directive('checkAddress', ['ajaxFactory', function (ajaxFactory) {
   return {
      restrict : 'EA',
      scope:{
        addressId : '='
      },
      templateUrl: 'address.html',  
      link: function (scope, elt ,attrs) {
    console.log(scope.addressId);
      }
     };
}]);

Unable to get scope.addressId. It is showing undefined. But my value is present in scope. If anyone know means please update. Thanks in advance.

Upvotes: 1

Views: 63

Answers (1)

Suresh Maruboina
Suresh Maruboina

Reputation: 28

app.directive('test', function(){
  return {
    restrict: 'A',
    scope: {
      myId: '@'
    },
    link: function(scope, iElement, iAttrs) {

      iAttrs.$observe('myId', function(value){
        alert(value);
      });      
    }
  };
});

Upvotes: 1

Related Questions