Skip to content
Open
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
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module.exports = function(grunt) {
livereload: 7777
},
assets: {
files: ['app/styles/**/*.css','app/scripts/**/*.js'],
files: ['app/styles/**/*.css','app/scripts/**/*.js', 'app/scripts/**/*.html', 'app/scripts/**/*.css'],
tasks: ['concat']
},
protractor: {
Expand Down
4 changes: 2 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

<body>
<div id="wrapper">
<header>Header</header>
<main id="view-container">
<div ng-view></div>
</main>
<footer>Footer</footer>
</div>
<script src="./assets/app.js"></script>
<script src="./scripts/components/stateful-component.js"></script>
<script src="./scripts/components/stateless-component/stateless-component.js"></script>
<script src="//localhost:7777/livereload.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions app/scripts/components/stateful-component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div style="background: green;
padding-bottom: 20px;
color: white;">
<h2>stateful-component</h2>
<pre>{{$ctrl.user | json}}</pre>
<stateless-component
user="$ctrl.user"
on-update="$ctrl.userUpdate($event)">
</stateless-component>
</div>
15 changes: 15 additions & 0 deletions app/scripts/components/stateful-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
angular.module('app.homePages')
.component('statefulComponent', {
templateUrl: './scripts/components/stateful-component.html',
controller: function(){

this.user = {
name: 'Jonny BeGood',
location: 'St. Louis, USA'
}

this.userUpdate = function($event) {
this.user = $event.user;
}
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div style="padding: 20px;
background: yellow;
margin: 20px;
color: black;">
<h3>stateless-component</h3>
<input type="text" ng-model="$ctrl.user.name">
<input type="text" ng-model="$ctrl.user.location">
<button ng-click="$ctrl.updateUser()">Update</button>
</div>
23 changes: 23 additions & 0 deletions app/scripts/components/stateless-component/stateless-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
angular.module('app.homePages')
.component('statelessComponent', {
templateUrl: './scripts/components/stateless-component/stateless-component.html',
bindings: {
user: '<',
onUpdate: '&'
},
controller: function(){
this.$onChanges = function(changes) {
if (changes.user) {
this.user = angular.copy(this.user);
}
}

this.updateUser = function() {
this.onUpdate({
$event: {
user: this.user
}
})
}
},
})
2 changes: 1 addition & 1 deletion app/scripts/homePages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ angular.module('app.homePages', [])

.controller('HomeCtrl', function($scope, welcomeMessage) {
$scope.welcome_message = welcomeMessage();
});
})
2 changes: 2 additions & 0 deletions app/templates/home.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{{ welcome_message }}
<stateful-component></stateful-component>

8 changes: 4 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version":"0.0.1",
"dependencies": {
"jquery": "~2.0.3",
"angular": "1.2.5",
"angular-route": "1.2.5",
"angular-animate": "1.2.5",
"angular-mocks": "1.2.5"
"angular": "^1.7.5",
"angular-loader": "^1.7.5",
"angular-route": "^1.7.5",
"angular-mocks": "^1.7.5"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-concat": "~0.3.0",
"grunt-open": "~0.2.2",
"bower": "~1.2.6",
"bower": "^1.2.6",
"karma-script-launcher": "~0.1.0",
"karma-firefox-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.0",
Expand Down