Skip to content

Commit

Permalink
Ajoute route
Browse files Browse the repository at this point in the history
  • Loading branch information
jbehuet committed Nov 20, 2014
1 parent 28f7705 commit e349694
Show file tree
Hide file tree
Showing 16 changed files with 1,083 additions and 40 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"tests"
],
"dependencies": {
"angular": "1.2.26"
"angular": "1.2.26",
"angular-route": "~1.2.26"
}
}
38 changes: 4 additions & 34 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,19 @@

<!-- ANGULARJS -->
<script src="js/libs/angular/angular.min.js"></script>
<script src="js/libs/angular-route/angular-route.js"></script>

<script src="js/controllers/main.js"></script>
<script src="js/services/messages.js"></script>
<script src="js/routes.js"></script>
<script src="js/app.js"></script>
</head>
<body ng-controller="mainController">
<body>
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<span class="navbar-brand"><a href="/">Atelier AngularJS</a> - Simplon Village 2014</span>
</div>
</div>
<div class="container">

<div>
<h3>Nouveau message</h3>
<div class="form-group">
<label>Votre nom</label>
<input type="text" class="form-control" ng-model="user" placeholder="Entre votre nome">
<label>Votre message</label>
<input type="text" class="form-control" ng-model="content" placeholder="Entre votre message">
</div>
<div class="form-group">
<button type="button" class="btn btn-success form-control" ng-click="add()">Ajouter</button>
</div>
</div>

<div class="form-group">
<label>Recherche</label>
<input type="text" class="form-control" ng-model="search" placeholder="Entre votre texte">
</div>
<table class="table table-condensed">
<tr>
<th>#</th>
<th>Utilisateur</tH>
<th colspan="2">Message</th>
</tr>
<tr ng-repeat="message in messages | filter: {content: search}">
<td>{{$index}}</td>
<td>{{message.user | uppercase }}</td>
<td>{{message.content}}</td>
<td><button type="button" class="btn btn-danger" ng-click="delete($index)" style="width:36px;float:right">x</button></td>
</tr>
</table>
</div>
<div ng-view></div>
</body>
</html>
5 changes: 3 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
angular
.module('app',[])
.module('app',['ngRoute'])
.controller("mainController", mainController)
.service("Messages", messagesService);
.service("Messages", messagesService)
.config(routes);
Empty file removed js/controllers/__init__.py
Empty file.
3 changes: 2 additions & 1 deletion js/controllers/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
function mainController($scope, Messages){
function mainController($scope, $location, Messages){
$scope.messages = Messages.get();

$scope.add = function(){
Messages.add({user: $scope.user, content: $scope.content});
$scope.user = "";
$scope.content = "";
$location.path("/");
};

$scope.delete = function(id){
Expand Down
18 changes: 18 additions & 0 deletions js/libs/angular-route/.bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "angular-route",
"version": "1.2.26",
"main": "./angular-route.js",
"dependencies": {
"angular": "1.2.26"
},
"homepage": "https://github.com/angular/bower-angular-route",
"_release": "1.2.26",
"_resolution": {
"type": "version",
"tag": "v1.2.26",
"commit": "896259f3c76d0e953b170ecae9258c349ee42c54"
},
"_source": "git://github.com/angular/bower-angular-route.git",
"_target": "~1.2.26",
"_originalSource": "angular-route"
}
54 changes: 54 additions & 0 deletions js/libs/angular-route/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# bower-angular-route

This repo is for distribution on `bower`. The source for this module is in the
[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngRoute).
Please file issues and pull requests against that repo.

## Install

Install with `bower`:

```shell
bower install angular-route
```

Add a `<script>` to your `index.html`:

```html
<script src="/bower_components/angular-route/angular-route.js"></script>
```

And add `ngRoute` as a dependency for your app:

```javascript
angular.module('myApp', ['ngRoute']);
```

## Documentation

Documentation is available on the
[AngularJS docs site](http://docs.angularjs.org/api/ngRoute).

## License

The MIT License

Copyright (c) 2010-2012 Google, Inc. http://angularjs.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading

0 comments on commit e349694

Please sign in to comment.