Skip to content
Merged

Task #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion my-todolist/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/


.idea
uploads

uploads/
54 changes: 51 additions & 3 deletions my-todolist/js/MainController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,64 @@
*/

function MainController($scope){
this.likelist=[];
this.myAmount=209.82;
this.myDate=1288323623006;
this.text="the text is here";
this.myarray=[
"angular","app"
];
this.addMovie=function(){
this.favourites.unshift({
title:this.newtitle,
year:this.release
}
)
};
this.unlike= function(index){
this.likelist.splice(index,1);
};
this.myObject={
one:"key1",
two:"key2"
};
this.addToLikes=function(movie)
{
// in function
this.likelist.push(movie);
};
this.favourites=[{
title:'the shawshank',
year:'1994',
popular:true
},{
title:'the shawshank',
year:'1994',
title:'excorcist',
year:'1995',
popular:false

}]
}
function UserController($http){
var API='/api/todo';
this.userId='';
this.chosenUser={};
this.getUser=function(){
if(!this.userId){
return;
}
$http.get(API+this.userId);
$http.then(function(response){
this.chosenUser=response.data;
console.log(this.chosenUser)
},function(reason){
console.log(reason)
});
$http.post()
}
}


angular.module('app1')
.controller('MainController',MainController)
.controller('MainController',MainController)
angular.module('app2')
.controller('UserController',UserController)
3 changes: 2 additions & 1 deletion my-todolist/js/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* Created by lcom64 on 30/1/17.
*/
angular.module('app1',[]);
angular.module('app1',[]);
angular.module('app2',[]);
Empty file added my-todolist/js/app2.js
Empty file.
53 changes: 51 additions & 2 deletions my-todolist/js/index1.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,60 @@
<script src="../lib/angular.js"></script>
</head>
<body>



<div ng-controller="MainController as main">
<li ng-repeat="movies in main.favourites">
<input type="text" placeholder="type to search" ng-model="main.myObject.two">
<pre>{{main.myObject|json}}</pre>
<a href="" ng-click="type='year'">Year</a>
<a href="" ng-click="type='title'">Title</a>
<div ng-repeat="like in main.likelist">
{{like.title}}
<a href="" ng-click="main.unlike($index);">Unlike</a>
</div>
<div ng-repeat="movies in main.favourites | orderBy:type:false|filter:{year:search}">
{{ movies.title }}
<a href="" ng-click="main.addToLikes(movies)">Add like</a>
<p ng-hide="!movies.popular">the movie is popular</p>
</li>
</div>
<div>
<form ng-submit="main.addMovie()">
<input type="text" placeholder="" ng-model="main.newtitle">
<input type="text" placeholder="" ng-model="main.release">
<button type="submit">Add new</button>
</form>
</div>
<!--index1.html
input tag

ng-focus="function name"
ng-blur="function name"
controller
this.functionname=function (){
}-->
{{main.myDate| date:'EEEE'}}<br>
{{main.myDate| date:'medium'}}<br>
{{main.myDate| date:'short'}}<br>
{{main.myDate| date:'longDate'}}<br>
{{main.myDate| date:'MMMM'}}<br>
{{main.myDate| date:'MM'}}<br>
{{main.myDate| date:'yyyy'}}<br>
{{main.myDate| date:'HH'}}<br>
{{main.myDate| date:'EEEE'}}<br>
{{main.myAmount|currency}}
{{main.myAmount|currency:'USD':1}}

<a href="" ng-click="Mykey='one'">
{{ main.myarray.length>0?
"Something here":
"Nothing here"
}}
</a>
<a ng-href="" target="_blank"> <img ng-src="../uploads/image" height="100" width="100"/></a>

{{main.myObject[Mykey]}}

</div>
<script src="app.js"></script>
<script src="MainController.js"></script>
Expand Down
19 changes: 19 additions & 0 deletions my-todolist/js/index2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html app="app2">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div ng-controller="UserController as user">
<form ng-submit="user.getUser()">
<input type="text" ng-model="user.userId">
<input type="submit">
Search user
</form>
<pre>{{user.chosenUser}}</pre>
</div>
<script src="app.js"></script>
<script src="MainController.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion my-todolist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"cookie-session": "~1.1.0",
"ejs": "~2.1.4",
"express": "~4.11.0",
"mongoose": "4.7,7",
"mongoose": "4.7.7",
"multer": "^1.2.1",
"validator": "6.2.1",
"path":"0.12.7",
Expand Down
Binary file not shown.