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
12 changes: 12 additions & 0 deletions src/about/about.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class controller {
/*@ngInject*/
constructor() {
this.title = 'About Us';
}
}

export default {
template: require('./about.html'),
controllerAs: 'AboutCtrl',
controller
}
8 changes: 8 additions & 0 deletions src/about/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="about">
<h1>{{ AboutCtrl.title }}</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iusto quis asperiores sapiente quisquam pariatur, quam dignissimos neque nemo unde nesciunt illo. Rem maxime, inventore asperiores quia quos nulla. Rerum, cum.</p>
<p>Ad eaque, cumque fugiat dolore delectus deserunt officia praesentium sed totam ullam rem explicabo error culpa nihil. Sequi aliquid aperiam totam architecto quae est reiciendis sapiente suscipit consequatur, excepturi id.</p>
<p>A perspiciatis fugit quibusdam distinctio facere, harum quae quasi rem sed dolorum nostrum inventore, deserunt doloremque vel et libero unde. Excepturi praesentium debitis repellat nemo, dolore dolorem quisquam autem vero!</p>
<p>Dignissimos autem optio quod inventore. Consectetur cupiditate rem eveniet illum optio perferendis corporis iste, repudiandae architecto molestiae voluptatem quibusdam natus laborum mollitia aliquid. Rerum eius maiores vitae tempora voluptatibus reprehenderit.</p>
<p>Laudantium non libero ratione corrupti incidunt modi animi sapiente provident laborum debitis. Esse assumenda ut magnam nihil eaque excepturi, nesciunt numquam porro. Fugit illum aspernatur fuga ea ab doloremque atque!</p>
</div>
21 changes: 21 additions & 0 deletions src/about/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import angular from 'angular';
import 'angular-ui-router';

import component from './about.component';

import './style.scss';


const module = angular.module('about.module', ['ui.router'])
.component('about', component)
.config(($stateProvider) => {
"ngInject"; // ng-annotate doesn't handle arrow functions automatically; need to add the directive prologue.
$stateProvider
.state('about', {
url: '/about',
template: '<about></about>'
});
})
.name;

export default module;
3 changes: 3 additions & 0 deletions src/about/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.about {
margin: 20px;
}
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import 'angular-sanitize';

import Components from './components';
import Home from './home';
import About from './about'

import appComponent from './application.component';

import './app.scss';


angular
.module('synopsis', ['ui.router', 'ngSanitize', Components, Home])
.module('synopsis', ['ui.router', 'ngSanitize', Components, Home, About])
.config(($locationProvider) => {
"ngInject"; // ng-annotate doesn't handle arrow functions automatically; need to add the directive prologue.
$locationProvider.html5Mode(true);
Expand All @@ -27,4 +28,3 @@ angular
angular
.element(document)
.ready(() => angular.bootstrap(document, ['synopsis']));

4 changes: 2 additions & 2 deletions src/components/navbar/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li ng-repeat="item in $ctrl.items" ng-class="{ active: item.isActive }">
<a ng-click="$ctrl.onItemClicked(item)" ng-href="{{ item.href }}">{{ item.label }}</a>
<li ng-repeat="item in $ctrl.items" ui-sref-active="active">
<a ui-sref="{{ item.href }}">{{ item.label }}</a>
</li>
</ul>

Expand Down
20 changes: 5 additions & 15 deletions src/components/navbar/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,17 @@ class NavBarController {
this.brand = 'Synopsis';

this.items = [{
href: '#',
label: 'Home',
isActive: true
href: 'home',
label: 'Home'
}, {
href: '#',
label: 'About',
isActive: false
href: 'about',
label: 'About'
}, {
href: '#',
label: 'Contact',
isActive: false
label: 'Contact'
}];

}

onItemClicked(clickedItem) {
this.items = this.items.map((item) => {
item.isActive = item.label === clickedItem.label;
return item;
});
}
}

const Navbar = {
Expand Down
15 changes: 1 addition & 14 deletions src/components/navbar/navbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../index'; // import the module under test

describe('Navbar Component', () => {

beforeEach(window.module('components.module'));
beforeEach(window.module('components.module'));

let $componentController;
beforeEach(window.inject((_$componentController_) => {
Expand All @@ -19,17 +19,4 @@ describe('Navbar Component', () => {
expect(component.items.length).toEqual(3);
});


describe('#onItemClicked', () => {
it('selects the clicked item', () => {
let component = $componentController('navbar', null, {});

var itemToClick = component.items[2];
expect(itemToClick.isActive).toBe(false);

component.onItemClicked(itemToClick);
expect(itemToClick.isActive).toBe(true);
});
});

});