So, i'm trying to add a modal to a page with a list of clients. When i open the modal i need it to have the data from that specific client.
I was able to do this when opening another pager, sending the id trought the url, but when i need to do this with the modal, i'm not able.
This is the code i have so far: Note: Without trying to open the specific data from client, everything is working fine.
page.html
<div class="col-md-6 cli--text">
<h3>{{client.name}}</h3>
<p ng-bind-html="client.desc | html"></p>
<a ng-click="clickToOpen({{client.id}})">More</a>
</div>
app.js
myApp.controller('CliCtrl', function ( $scope, $http, $routeParams, modals, ngDialog) {
$scope.get_client = function() {
$http.get("scripts/data/client.json")
.success( function(data) {
$scope.pagedclient = data;
})
.error(function(data) {
alert("Something wrong.");
});
};
$scope.clickToOpen = function (data) {
ngDialog.open({
template: 'scripts/data/modal.html',
closeByDocument: true,
closeByEscape: true
});
function getById(arr, id) {
for (var d = 0, len = arr.length; d < len; d += 1) {
if (arr[d].id === id) {
return arr[d];
}
}
}
$scope.get_client().then(function(){
$scope.clients = getById($scope.detRes,data);
});
$scope.nameclient = clients.name;
};
});
modal.html
<div class="modal--body">
<h2>Modal template</h2>
<h3>{{nameclient}}</h3>
</div>
I'm using this modal plugin, but since i'm new to AngularJS, i don't know exactly what to do.