-3

angular.element.inheritedData(key)

Above method is available in angular js. This method is also mentioned in this web page. ==> https://docs.angularjs.org/api/ng/function/angular.element But that does not explain how to use this method.Please give me some examples. These days I am studying angularjs. I could not find any example.

3
  • stackoverflow.com/questions/30341968/… Commented May 27, 2015 at 10:15
  • This is a very poor question. The title does not reflect what is being asked. Please edit, this needs to be clear to anyone reading this later on. Commented May 27, 2015 at 10:58
  • Both the title and the tags are important. You should include angular.element.inheritedData(key) in the title. Commented May 27, 2015 at 13:24

2 Answers 2

1

We can fetch the data associated with an element’s $scope simply by using the inheritedData() method on the element:

element.inheritedData();

This inheritedData() finds data up the scope chain as it walks up the DOM until it’s found a particular value has been reached.

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.name = 'World';
  $scope.displayForm = function(e){
    var form = angular.element(e.target)
        .inheritedData('$formController');
    $scope.form_name = form.$name;
  };
});
Sign up to request clarification or add additional context in comments.

Comments

0

Here one input text box

<input type="text" name="icontext">

now we will get this using angular.element

angular.element("input[name='icontext']").val();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.