person
using the module pattern.person
service keeps its details
including firstName
and lastName
private.person
service exposes the getFirstName
method.HelloCntl
using a constructor function passing it the person
service.HelloCntl
controller exposes the sayHello
method which returns a greeting (as as a string) getting the name from the person
service.
var person = (function () {
var details = {
firstName : 'John',
};
return {
getFirstName : function () {
return details.firstName;
}
};})(),
HelloCntl = function (person) {
this.sayHello = function () {
return 'Hello ' + person.getFirstName() + '!';
};
}, helloCntl1;
helloCntl1 = new HelloCntl(person);
console.log(helloCntl1.sayHello());
Create form for editing user profile
userProfile{
firstName:'' //min-length=3, required
lastName:'' //min-length=3, required
password:'' //required
email:'', //required valid email
isCustomer:'' //yes or no
}
Form should have the following features:
Create directive for simple tab bar
$scope.tabs = [
{
title: 'Tab1',
content: 'Content of Tab1'
},
{
title: 'Tab2',
content: 'Content of Tab2'
}
];
Directive should render the following widget
.directive('tabBar', function(){
return {
restrict:'E',
templateUrl:'tabbar.html',
scope:{
tabs:'='
},
link: function(scope, element, attr){
scope.currentTab=0;
scope.select=function(index){
scope.currentTab=index;
};
}
};
});