Skip to content

Commit

Permalink
[enhancement] directive working #58
Browse files Browse the repository at this point in the history
  • Loading branch information
SylTi committed Nov 30, 2014
1 parent a0c8d63 commit b9a61ac
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 44 deletions.
5 changes: 5 additions & 0 deletions client/app/admin/admin.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ angular.module('bitCrowdFundsApp')
$scope.message = 'Something wrong happend';
});
};
//console.log($scope.projects);
/*$scope.$watch('projects', function(newVal, oldVal) {
console.log($scope.projects);
}, true);*/

/*$scope.$watch('projects', function(projs)
{
Expand Down
3 changes: 2 additions & 1 deletion client/app/admin/admin.jade
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ div(ng-include='"components/navbar/navbar.html"')
ul.list-group.well
tabset(justified='true', type="'pills'")
tab(heading='All').tabText.label-primary
span(adminProjectList projects="projects")
li.list-group-item(ng-repeat='project in projects')
admin-project-list
//- li.list-group-item(ng-repeat='project in projects')
//- strong
//- span.label.label-success(ng-show="project.amountRaised >= project.amountToRaise") Finished
Expand Down
55 changes: 34 additions & 21 deletions client/components/adminProjectList/adminProjectList.directive.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
'use strict';

angular.module('bitCrowdFundsApp')
.directive('adminProjectList', function () {
.directive('adminProjectList', function ($timeout) {
return {
//templateUrl: 'components/adminProjectList/adminProjectList.html',
templateUrl: 'components/adminProjectList/adminProjectList.html',
restrict: 'EA',
//replace: true,
//transclude: true,
//scope: true
scope: {
projects: '='
},
//replace: true,
//transclude: true,
/*controller: function($scope)
//template: '<div>this is my template</div>',
/*scope: {
project: '='
},*/
link: function (scope,el, attrs)
{
$scope.$watch('projects', function(v) {
$scope.projects = v;
/*scope.$watch('project', function (newMyData) {
//Build the table and insert it into DOM
});
}*/
link: function(scope, element, attrs)
{
element.text('<div>shit</div>');
scope.$on("Data_Ready", function ()
console.log("before: " + el.html());
$timeout(function()
{
element.text('<div>shit</div>');
});
}
console.log("After: " + el.html());
$timeout(function()
{
console.log("After2: " + el.html());
}, 0);
}, 0);
$timeout(function ()
{
console.log('HERE');
});*/
},
/*template:
[
//'<li class="list-group-item" ng-repeat=\'project in projects\'>',
'<strong>',
'<span class="label label-success" ng-show="project.amountRaised >= project.amountToRaise"> Finished</span>',
'<span> clas="label label-warning" ng-show="project.amountRaised !== 0 && project.amountRaised < project.amountToRaise"> Ongoing</span>',
'<span> class="label label-default" ng-show="project.amountRaised === 0"> Not started</span>',
'&nbsp;&nbsp;',
'<span> {{project.name}} ({{project.amountRaised | toBTC}} / {{project.amountToRaise | toBTC}}</span>'
].join('')*/
//template: 'test'
};
});
43 changes: 21 additions & 22 deletions client/components/adminProjectList/adminProjectList.jade
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
li.list-group-item(ng-repeat='project in projects')
strong
span.label.label-success(ng-show="project.amountRaised >= project.amountToRaise") Finished
span.label.label-warning(ng-show="project.amountRaised !== 0 && project.amountRaised < project.amountToRaise") Ongoing
span.label.label-default(ng-show="project.amountRaised === 0") Not started
| &nbsp;&nbsp;
span {{project.name}} ({{project.amountRaised | toBTC}} / {{project.amountToRaise | toBTC}})
br
small.text-muted
span Project created
| &nbsp;
b(am-time-ago="project.dateCreat")
| &nbsp;
span and finishing
| &nbsp;
b(am-time-ago="project.dateEndCampaign")
.pull-right
a(ng-href='/projects/{{project.slug}}/edit')
span.glyphicon.glyphicon-pencil
| &nbsp;&nbsp;&nbsp;&nbsp;
a.trash(ng-click='deleteProject(project)')
span.glyphicon.glyphicon-trash
strong
span.label.label-success(ng-show="project.amountRaised >= project.amountToRaise") Finished
span.label.label-warning(ng-show="project.amountRaised !== 0 && project.amountRaised < project.amountToRaise") Ongoing
span.label.label-default(ng-show="project.amountRaised === 0") Not started
| &nbsp;&nbsp;
span {{project.name}} ({{project.amountRaised | toBTC}} / {{project.amountToRaise | toBTC}})
br
small.text-muted
span Project created
| &nbsp;
b(am-time-ago="project.dateCreat")
| &nbsp;
span and finishing
| &nbsp;
b(am-time-ago="project.dateEndCampaign")
.pull-right
a(ng-href='/projects/{{project.slug}}/edit')
span.glyphicon.glyphicon-pencil
| &nbsp;&nbsp;&nbsp;&nbsp;
a.trash(ng-click='deleteProject(project)')
span.glyphicon.glyphicon-trash

0 comments on commit b9a61ac

Please sign in to comment.