Skip to content

Commit

Permalink
Closes #19 p2c7 Que sont les filtres ? See #1 general : Human tested …
Browse files Browse the repository at this point in the history
…OK ; no console error
  • Loading branch information
moueza committed Sep 7, 2019
1 parent 0a6741a commit c4de43b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 271 deletions.
92 changes: 10 additions & 82 deletions workspace/first-app/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,94 +21,22 @@

<!-- Add your site or application content here -->




<div >
<div ng-controller="exemple1Ctrl">
<input ng-model="age"/>
<span>Vous êtes <b ng-bind="majeurOrMineurText()"></b></span>
</div>
</div>



<div >
<div ng-controller="myController">
<label>Afficher le paragraphe</label>
<input type="checkbox" ng-model="showContent"/>
<p ng-show="showContent">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<div >
<div ng-controller="exempleCtrl">
HELLO {{name}}!
</div>
</div>
<div ng-app="app">
<div ng-controller="BillCtrl">
<ul>
<li ng-repeat="article in articles">
<label>{{article.name}}:</label>
<input ng-model="article.price"/>
<input type="number" ng-model="article.quantity"/>
</li>
</ul>
<div>
<label>Total facture: </label><span>{{total() | currency:"€":2}}</span>
</div>
<div>
<label>Réduction: </label><span>{{discount| currency: "€":2}}</span>
</div>
<div>
<label>Somme à payer: </label><span>{{finalTotal() | currency: "€":2}}</span>
</div>
</div>
</div>

<!--
<div >
<div ng-controller="SomeController">
<expander class="expander" expander-title="title">
{{text}}
</expander>
</div>
</div>-->





<div >
<div ng-controller="SomeController">
<accordion>
<expander class="expander" expander-title="expander.title" ng-repeat="expander in expanders">
{{expander.text}}
</expander>
</accordion>
</div>
</div>




<div ng-controller="myController">
<span>{{'2012-04-01'| date: 'dd MMM yyyy'}}</span>
</div>

<div >
<div ng-controller="factoryCtrl">
factory : {{fact}}
<div>
Cet article vaut <span>
{{15.5879|currency:'€':2}}</span>
</div>
</div>
<div >
<div ng-controller="serviceCtrl">
factory : {{serv}}
<div>
<span>
{{'todo'|uppercase}}
</span>
</div>
</div>

<div >
<div ng-controller="providerCtrl">
provider : {{providerr}}
</div>
</div>

<!-- Google Analytics: change UA-XXXXX-X to be your site's ID -->
<script>
Expand Down
190 changes: 1 addition & 189 deletions workspace/first-app/app/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,195 +16,7 @@ angular.module('firstAppApp')
});

var myApp = angular.module('firstAppApp', []);
myApp.controller("exemple1Ctrl", function ($scope) {
$scope.age = 0;
$scope.majeurOrMineurText = function () {
return ($scope.age >= 18) ? "majeur" : "mineur";
};
});






//var app = angular.module("firstAppApp", []);
myApp.controller("myController", function ($scope) {
$scope.showContent = true;
});


myApp.controller("exempleCtrl", function ($scope) {
$scope.name = "World"
});




myApp.controller("BillCtrl", function ($scope) {
$scope.articles = [{"name": "Téléphone sans-fil", "quantity": 1, "price": "29.99"}, {"name": "Chargeur iPhone5", "quantity": 1, "price": "29.99"}];
$scope.total = function () {
var total = 0;
for (var i = 0; i < $scope.articles.length; i++) {
total += $scope.articles[i].price * $scope.articles[i].quantity;
}
return total;
};
function calculateDiscount(newValue, oldValue, scope) {
$scope.discount = (newValue > 100) ? newValue * 0.10 : 0;
}
;

$scope.finalTotal = function () {
return $scope.total() - $scope.discount;
};

$scope.$watch($scope.total, calculateDiscount);
});


//var app = angular.module("app", []);

myApp.controller("SomeController", function ($scope) {
$scope.title = "Titre";
$scope.text = "Contenu";
});
//
//myApp.directive("expander", function () {
// return {
// restrict: 'EA',
// replace: true,
// transclude: true,
// scope: {title: '=expanderTitle'},
// template: '<div>' +
// '<div class="title" ng-click="toggle()">{{title}}</div>' +
// '<div class="body" ng-show="showMe" ng-transclude></div>' +
// '</div>',
// link: function (scope, element, attrs) {
// scope.showMe = false;
// scope.toggle = function toggle() {
// scope.showMe = !scope.showMe;
// };
// }
// };
//});


//var app = angular.module("app", []);

myApp.controller("SomeController", function ($scope) {
$scope.expanders = [
{title: 'Titre 1',
text: 'Contenu 1'},
{title: 'Titre 2',
text: 'Contenu 2'},
{title: 'Titre 3',
text: 'Contenu 3'}
];
});

myApp.directive("accordion", function () {
return{
restrict: 'EA',
replace: true,
transclude: true,
template: "<div ng-transclude></div>",
controller: function () {
var expanders = [];
this.gotOpened = function (selectedExpander) {
expanders.forEach(function (expander) {
if (selectedExpander != expander) {
expander.showMe = false;
}
});
};
this.addExpander = function (expander) {
expanders.push(expander);
};
}
};
});

myApp.directive("expander", function () {
return {
restrict: 'EA',
replace: true,
transclude: true,
require: '^?accordion',
scope: {title: '=expanderTitle'},
template: '<div>' +
'<div class="title" ng-click="toggle()">{{title}}</div>' +
'<div class="body" ng-show="showMe" ng-transclude></div>' +
'</div>',
link: function (scope, element, attrs, accordionController) {
scope.showMe = false;
accordionController.addExpander(scope);
scope.toggle = function toggle() {
scope.showMe = !scope.showMe;
accordionController.gotOpened(scope);
};
}
};
});

myApp.factory("factoryExample", function () {
return{
service1: function () {
var stringg = "chn";
return stringg;
},
service2: function () {},
}
});

myApp.controller("factoryCtrl", function ($scope, factoryExample) {
$scope.fact = factoryExample.service1();
});



////////////////////

myApp.service("serviceExample", function () {
this.service1 = function () {
var stringg = "chnService";
return stringg;
};
this.service2 = function () {
null
};
});

myApp.controller("serviceCtrl", function ($scope, serviceExample) {
$scope.serv = serviceExample.service1();
});

//////////////////////////////
myApp.provider("greeter", function () {
var salutation = "Hello";
this.setSalutation = function (_salutation) {
salutation = _salutation;
};

function Greeter() {
this.greet = function () {
return salutation;
};
}
;

this.$get = function () {
return new Greeter();
};
});

//var app = angular.module("app", []).config(function (greeterProvider) {
myApp.config(function (greeterProvider) {
greeterProvider.setSalutation("Bonjour provider service");
});

//It needs to be called in view to operate
myApp.controller('providerCtrl', function ($scope, greeter) {
console.log(greeter.greet());
$scope.providerr = 'my provider';
});

0 comments on commit c4de43b

Please sign in to comment.