Binding model inside model in angularjs

Mayur

I am trying to add model inside model but it is showing {{filterText}} instead of showing text.

Below is my text which will brief how i am trying:

$scope.filterText = "rooms";  //text will changed by user when ever he will require
$scope.items = [{"id":"1","title":"10 {{item.filterText}}","filterText":"care"},{"id":"2","title":"5 {{item.filterText}}","filterText":"rooms"},{"id":"3","title":"8 {{item.filterText}}","filterText":"Take"}];

In html page:

<div ng-repeat="item in items">
Title : {{item.title}}
</div>

Right now i am getting result as:

Title : 10 {{item.filterText}}

Title : 5 {{item.filterText}}

Title : 8 {{item.filterText}}

But i need:

Title : 10 care

Title : 5 rooms

Title : 8 Take

I am struggling to achieve. but i am not able to achieve it how to do this?

rejo

Try this , its working . Use $interpolate , link

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

app.controller('MainCtrl', function($scope,$interpolate) {
$scope.filterText = "rooms";  //text will changed by user when ever he will require
$scope.items = $scope.items = [{"id":"1","title":"10 {{item.filterText}}","filterText":"care"},{"id":"2","title":"5 {{item.filterText}}","filterText":"rooms"},{"id":"3","title":"8 {{item.filterText}}","filterText":"Take"}];;


$scope.compiledItems = [];
for(var i=0;i<$scope.items.length;i++){
  $scope.item = {};
  $scope.item.filterText = $scope.items[i].filterText;
  var text = $interpolate($scope.items[i].title)($scope); 
  $scope.compiledItems.push(text); 
}

});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
  <body ng-app="plunker" ng-controller="MainCtrl">
    <div ng-repeat="item in compiledItems">
      Title : {{item}}
     </div> 
  </body>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Binding model inside model in angularjs

From Dev

list of model binding angularjs

From Dev

AngularJS binding not updating model

From Dev

Model values are not binding with editor Angularjs

From Dev

angularjs dynamically change model binding

From Dev

Binding Select Option to Model AngularJS

From Dev

Model values are not binding with editor Angularjs

From Dev

AngularJS : Binding ngrepeat values to model in AngularJS

From Dev

Assigning AngularJS model inside ngRepeat

From Dev

Dynamic ng-model binding inside a directive

From Dev

Model binding not working inside a partial view

From Dev

Model binding not working inside a partial view

From Dev

Injecting IHttpContextAcessor into a Binding Model inside an Controller Action

From Dev

Hidden Input and AngularJS ng-model binding

From Dev

AngularJS and Play Framework model binding and templates

From Dev

Binding value into TinyMCE <textarea> using AngularJS model

From Dev

select dropdown not binding initially to AngularJS model

From Dev

AngularJS: Select not 2-way binding to model

From Dev

Changing Kendo chart type by model binding in AngularJS

From Dev

How to create dictionary like model binding in AngularJS

From Dev

Angularjs select ng-model binding for object

From Dev

AngularJS dynamic input value binding to an array model

From Dev

Servicestack + model binding on json post using AngularJs

From Dev

How to create dictionary like model binding in AngularJS

From Dev

AngularJS directive dynamic model binding to view

From Dev

AngularJS dynamic input value binding to an array model

From Dev

Angularjs ng-model not binding to hidden input

From Dev

Model binding with a sub model

From Dev

Model collection inside a Model

Related Related

  1. 1

    Binding model inside model in angularjs

  2. 2

    list of model binding angularjs

  3. 3

    AngularJS binding not updating model

  4. 4

    Model values are not binding with editor Angularjs

  5. 5

    angularjs dynamically change model binding

  6. 6

    Binding Select Option to Model AngularJS

  7. 7

    Model values are not binding with editor Angularjs

  8. 8

    AngularJS : Binding ngrepeat values to model in AngularJS

  9. 9

    Assigning AngularJS model inside ngRepeat

  10. 10

    Dynamic ng-model binding inside a directive

  11. 11

    Model binding not working inside a partial view

  12. 12

    Model binding not working inside a partial view

  13. 13

    Injecting IHttpContextAcessor into a Binding Model inside an Controller Action

  14. 14

    Hidden Input and AngularJS ng-model binding

  15. 15

    AngularJS and Play Framework model binding and templates

  16. 16

    Binding value into TinyMCE <textarea> using AngularJS model

  17. 17

    select dropdown not binding initially to AngularJS model

  18. 18

    AngularJS: Select not 2-way binding to model

  19. 19

    Changing Kendo chart type by model binding in AngularJS

  20. 20

    How to create dictionary like model binding in AngularJS

  21. 21

    Angularjs select ng-model binding for object

  22. 22

    AngularJS dynamic input value binding to an array model

  23. 23

    Servicestack + model binding on json post using AngularJs

  24. 24

    How to create dictionary like model binding in AngularJS

  25. 25

    AngularJS directive dynamic model binding to view

  26. 26

    AngularJS dynamic input value binding to an array model

  27. 27

    Angularjs ng-model not binding to hidden input

  28. 28

    Model binding with a sub model

  29. 29

    Model collection inside a Model

HotTag

Archive