javascript - AngularJS + MEANJS - Use object model property as array key for filter -
i have meanjs app crud module of countries. when click on country default list view, brings me view-country.client.view. have added field model currencycode. when click country bring me page want bring exchange rate json matching currencycode field of country model data json import.
//view-country.client.view <section data-ng-controller="countriescontroller" data-ng-init="findrate()"> <div class="col-lg-3 col-md-6 col-sm-12"> <div class="panel panel-dark"> <div class="panel-heading">currency</div> <div class="panel-body"> {{country.currencycode}} <p>the exchange rate {{exchangerates.rates['afn']}} </div> </div> </div> </section> //findrate() data-ng-init in countriescontroller $scope.findrate = function() { $scope.country = countries.get({ countryid: $stateparams.countryid }); $http.get('http://localhost:3000/rates.json'). success(function(data) { $scope.exchangerates = data }); };
everything working json import , if include countrycode (in example 'afn' afghanistan), return correct rate. {{country.currencycode}} brings afn mongodb if try , embed {{country.currencycode}} 'afn' is, not work. have tried looking @ filters cannot work. basically, anytime click country, want show rate country using model property string getting correct object array. have been in forums day , cannot figure out. thank in advance.
if understood correct, don't want 'afg' hardcoded here?
{{exchangerates.rates['afn']}}
if that's case have tried this?
{{exchangerates.rates[country.currencycode]}}
Comments
Post a Comment