Angularjs load json into a specific div -
i'm new angularjs love framework.
what have right now, (stub) single page loads json data.
js
var merlinoapp = angular.module('merlino', []); merlinoapp.controller('maincontroller', function ($scope, $http) { ... $http.get('@url.action( "consoledatapull", "consoleelaborazioni")') .then(function (res) { $scope.jobs = res.data.jsonjobs; $scope.clienti = res.data.jsonclienti; $scope.console = res.data.jsonconsole; }); ... }); html
<div ng-repeat="roll in jobs | orderby:sorttype:sortreverse | filter:searchjob | filter:searchcliente | filter:searchstato" class="console-row my-row"> ... <div class="console-cell-id console-cell console-cell-padding console-cell-no-border-sx">{{ roll.id }}</div> ... <div ng-click="collapsed=!collapsed" ng-class="{'console-cell-esito-selected' : collapsed}" class="console-cell-esito console-cell console-cell-no-border-sx">short desc</div> <div ng-show="collapsed" class="console-cell-esito-long console-cell console-cell-no-border-sx">{{ roll.esito }}</divng-show></div> </div> this populates ng-repeat, , ng-click shows/hides `ng-show div. far good(?).
what Ì'm trying achieve, load json data
<div ng-show="collapsed" class="console-cell-esito-long... if
<div ng-click="collapsed=!collapsed" ng-class="{'console-cell... is clicked.
each div of ng-repeat, can loaded specific data:
<ul> <li ng-repeat="logelem in jsonlog"> {{ logelem.log }} </li> </ul> i thought using function:
<div ng-click="function(id)... and load json div identified id, used $index...
result was, being able load same data divs @ once :/
help appreciated.
my suggestion woudl add information jobs elements itself.
so example, ng-click become:
<div ng-click="loaddata(id, roll)">click me</div> and loaddata like:
$scope.loaddata = function(id, roll){ // roll.result = result; } and can use result object in view in other places. can example hide object want final result until variable result defined.
i think easiest solution.
update comments
why not change collapsed value in method? or use $watch listen changes on collapsed variable.
Comments
Post a Comment