Hi Dries,
sure:
<td class="calendar-unit" ng-repeat="day in days" ng-init='assignments=getAssignments(employee,day)'>
{{day.date()}}
<div class="assignment" ng-repeat="assignment in assignments">
{{assignment.type}}
</div>
</td>
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Oho, I didn't even notice the day in days ng-repeat. Yeah, in that case, this feels either like time to do one big request or time to do something like explicit controllers or a directive.
Given the repeats, I'd consider a directive (or even nested directives) if you end up wanting to make any complex view state variables per day or per assignment (like expanded or whatever).
E
Hi Tan,
That is what I meant that you needed an extra controller! You don’t even need the ng-Init anymore now.
change your controller a bit so it looks like this:
app.controller('assignmentCtrl', [
'$scope',
function($scope) {
//set up the empty array, so angular start with binding an empty array!
$scope.assignments = [];
// you can use the $scope variables from the parent scope in here!
$http.get('something.php?emp=' + $scope.employee + '&d=' + $scope.day)
.then(function(response) {
$scope.assignments = response.data;
});
}
]);
and your HTML:
<td class="calendar-unit" ng-repeat="day in days" ng-controller='assignmentCtrl'>
{{day.date()}}
<div class="assignment" ng-repeat="assignment in assignments">
{{assignment.type}}
</div>
</td>
Regards
Sander
Thank you guys for your help...
<div class="application-category-list col-md-9"> <ul> <li ng-repeat-start="version in ctrl.applicationVersion | orderBy: 'id'" ng-repeat-end ng-init="ctrl.getApplicationByVersion(version.id)"> <div class="row"> <div class="application-category"> <h4>{{version.name}}</h4> </div> </div> <div class="row"> <ul class="application-card-list"> <li class="col-xs-12 col-sm-3 col-md-2" ng-repeat-start="application in ctrl.applicationByVersion" ng-repeat-end> <div class="application-card-box"> <div class="application-card-image"> <a href=""><img src="assets/img/application/apps_1.png" alt=""></a> </div> <div class="application-card-body"> <a href=""><p class="application-card-title">{{application.name}}</p></a> <p class="application-card-subtitle">{{application.version.name}}</p> <p class="application-card-version">{{application.number}}</p> </div> </div> </li> </ul> </div> </li> </ul></div>
app.controller('ApplicationController', ['$scope', 'config', 'ApplicationService', function ($scope, config, ApplicationService) { var vm = this; var countApplicationByVersion = 6; var countApplicationTopUsing = 5; vm.title = 'App Center'; vm.applicationTopUsingtitle = 'Top Using Apps'; vm.assetsUrl = config.assetsUrl; vm.pathApplication = config.pathApplication; vm.pathApplicationVersion = config.pathApplicationVersion; vm.applicationVersion = []; vm.applicationByVersion = []; vm.applicationTopUsing = []; vm.getApplicationVersion = function () { ApplicationService.getApplicationVersion() .then( function (applicationVersion) { vm.applicationVersion = applicationVersion; }, function (data) { console.log(data) } ); } vm.getApplicationByVersion = function (id) { if(id != null){ ApplicationService.getApplicationByVersion(id, countApplicationByVersion) .then( function (applicationByVersion) { vm.applicationByVersion = applicationByVersion; console.log(vm.applicationByVersion); console.log(applicationByVersion.length); }, function (data) { console.log(data) } ); } } vm.getApplicationTopUsing = function () { ApplicationService.getApplicationTopUsing(countApplicationTopUsing) .then( function (applicationTopUsing) { vm.applicationTopUsing = applicationTopUsing; }, function (data) { console.log(data); } ); }; vm.getApplicationVersion(); vm.getApplicationByVersion(); vm.getApplicationTopUsing();}]);
app.service('ApplicationService', ['$http', '$q', 'config', function ($http, $q, config) { var factory = { applicationVersion: [], applicationByVersion: [], applicationTopUsing: [], getApplicationVersion: getApplicationVersion, getApplicationByVersion: getApplicationByVersion, getApplicationTopUsing: getApplicationTopUsing }; function getApplicationVersion() { var defer = $q.defer(); var data = { page: 0, size: 0 }; var cfg = { params: data, header: { 'enctype': 'multipart/form-data', 'accept': 'application/json' } }; $http.get(config.apiUrl + 'version', cfg) .then( function (response) { //success callback if(response.status == 200) { factory.applicationVersion = response.data.data.versions; defer.resolve(response.data.data.versions); } }, function (response) { //failure callback defer.reject('Failed to get data'); } ); return defer.promise; } function getApplicationByVersion(versionId, size) { var defer = $q.defer(); var data = { page: 0, size: size }; var cfg = { params: data, header: { 'enctype': 'multipart/form-data', 'accept': 'application/json' } }; $http.get(config.apiUrl + 'application/version/' + versionId, cfg) .then( function (response) { //success callback if(response.status == 200) { factory.applicationByVersion = response.data.data.applications; defer.resolve(response.data.data.applications); } }, function (response) { //failure callback defer.reject('Failed to get data'); } ); return defer.promise; } function getApplicationTopUsing(size) { var defer = $q.defer(); var data = { page: 0, size: size }; var cfg = { params: data, header: { 'enctype': 'multipart/form-data', 'accept': 'application/json' } }; $http.get(config.apiUrl + 'application/top/using', cfg) .then( function (response) { //success callback if(response.status == 200) { factory.applicationTopUsing = response.data.data.applications; defer.resolve(response.data.data.applications); } }, function (response) { //failure callback defer.reject('Failed to get data'); } ); return defer.promise; }; return factory;}]);
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/Qb84aYryMG0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
finally i am using array. thanks
On Fri, Jul 22, 2016 at 9:38 PM, Sander Elias <sande...@gmail.com> wrote:
Hi Paijo.Every row has it's own 'scope' (dont' use that!!) Most of what you need is taken care of automatically. But you have only 1 controller, and if you want to store multiple variants for multiple rows, you can store it in the data of the row itself, or keep an parallel array.RegardsSander
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/Qb84aYryMG0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/Qb84aYryMG0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.