Not able to get the value from the `directive` scope

3gwebtrain

I am trying to get the value from ng-repeat directive, but only i am consoled by $index, the value consoles as undefiend.

what is wrong here?

my code :

HTML:

<body ng-controller="main">
     <h1>{{index}}</h1>

     <new-array index='$index' ng-repeat="value in values">{{value}}</new-array>
  </body>

JS:

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

myApp.controller('main', function ($scope) {

  $scope.values = [{"name":"one", "num" : 1}, {"name":"two", "num" : 2}, {"name":"three", "num" : 3}]

  $scope.index = 0;

  $scope.update = function (num) {
    $scope.index = num;
  }

});

myApp.directive("newArray", function () {

  return {

    scope : {
      value : "=",
      index : "="
    },

    link : function (scope, element, attrs) {

      console.log(scope.value, scope.index)
      //reusult as "undefined" 1

    }

  }

})

Live Demo

Dmitry Pavliv

This

<new-array index='$index' ng-repeat="value in values">{{value}}</new-array>

should be

<new-array index='$index' value='value' ng-repeat="value in values">{{value}}</new-array>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Not able to get the value from the `directive` scope

From Dev

Not able to get the = Local scope value inside directive

From Dev

Not able to update the `scope` value from directive function

From Dev

Get value from directive to $scope in controller

From Dev

Unable to get value from scope using directive

From Dev

Changing a scope value from a directive

From Dev

Change controller scope value from directive AngularJS

From Dev

Use, in child directive, value from parent directive and $scope

From Dev

Use, in child directive, value from parent directive and $scope

From Dev

How to change all directive scope value from any one of directive?

From Dev

AngularJS : How to change scope value from isolated scope within directive

From Dev

Get value from Directive into Controller

From Dev

Change a scope value in directive

From Dev

Pass value from child directive isolated scope to parent directive isolated scope and trigger watch of parent

From Dev

AngularJS : Directive not able to access isolate scope objects

From Dev

AngularJs: Directive with function for template property. How to get scope value?

From Dev

AngularJs: Directive with function for template property. How to get scope value?

From Dev

How to get updated value for isolated scope using angular directive?

From Dev

Not able to obtain value in view (directive)

From Dev

AngularJS : Change parent scope value from custom directive

From Dev

How to pass value back from angularjs directive scope with javascript event

From Dev

AngularJS : directive binding value to parent scope from template model

From Dev

Change Controller variable value from change in isolate scope directive

From Dev

AngularJS : directive binding value to parent scope from template model

From Dev

Angularjs directive - cannot retrieve value from isolated scope

From Dev

How to pass value back from angularjs directive scope with javascript event

From Dev

AngularJS - Not able to get value from factory service

From Dev

Not able to get a value from yml file in groovy

From Dev

@Value with SpEL not able to get values from properties

Related Related

  1. 1

    Not able to get the value from the `directive` scope

  2. 2

    Not able to get the = Local scope value inside directive

  3. 3

    Not able to update the `scope` value from directive function

  4. 4

    Get value from directive to $scope in controller

  5. 5

    Unable to get value from scope using directive

  6. 6

    Changing a scope value from a directive

  7. 7

    Change controller scope value from directive AngularJS

  8. 8

    Use, in child directive, value from parent directive and $scope

  9. 9

    Use, in child directive, value from parent directive and $scope

  10. 10

    How to change all directive scope value from any one of directive?

  11. 11

    AngularJS : How to change scope value from isolated scope within directive

  12. 12

    Get value from Directive into Controller

  13. 13

    Change a scope value in directive

  14. 14

    Pass value from child directive isolated scope to parent directive isolated scope and trigger watch of parent

  15. 15

    AngularJS : Directive not able to access isolate scope objects

  16. 16

    AngularJs: Directive with function for template property. How to get scope value?

  17. 17

    AngularJs: Directive with function for template property. How to get scope value?

  18. 18

    How to get updated value for isolated scope using angular directive?

  19. 19

    Not able to obtain value in view (directive)

  20. 20

    AngularJS : Change parent scope value from custom directive

  21. 21

    How to pass value back from angularjs directive scope with javascript event

  22. 22

    AngularJS : directive binding value to parent scope from template model

  23. 23

    Change Controller variable value from change in isolate scope directive

  24. 24

    AngularJS : directive binding value to parent scope from template model

  25. 25

    Angularjs directive - cannot retrieve value from isolated scope

  26. 26

    How to pass value back from angularjs directive scope with javascript event

  27. 27

    AngularJS - Not able to get value from factory service

  28. 28

    Not able to get a value from yml file in groovy

  29. 29

    @Value with SpEL not able to get values from properties

HotTag

Archive