зеркало из https://github.com/DeGsoft/meanjs.git
componenete sumar
This commit is contained in:
Родитель
871f8b46a4
Коммит
71f2d83ddd
|
@ -0,0 +1,43 @@
|
|||
<!--Directiva ng-app para indicarle a AngularJS que debe ejecutarse sobre este documento-->
|
||||
<html ng-app="app">
|
||||
|
||||
<head>
|
||||
<title>Hola AngularJS</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta lang="es" />
|
||||
<meta name="description" content="Tutorial simple Hola Mundo en AngularJS por Alberto Basalo" />
|
||||
<meta name="author" content="Alberto Basalo @ Ágora Binaria" />
|
||||
<meta name="application-name" content="HolaAngularJS" />
|
||||
<meta name="Keywords" content="AngularJS, ejemplo, tutorial, curso, ng-app" />
|
||||
<link rel="author" href="https://plus.google.com/+AlbertoBasalo71" />
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body class="container-fluid" ng-init="a=4; b=5">
|
||||
|
||||
<sumar a="{{a}}" b="{{b}}" ></sumar>
|
||||
|
||||
<script>
|
||||
angular.module('app',[])
|
||||
.directive('sumar',function(){
|
||||
return{
|
||||
template:'<span>{{ sumar.a + sumar.b }} -- {{ sumar.suma() }}</span>',
|
||||
scope:{
|
||||
a:"@",
|
||||
b:"@"
|
||||
},
|
||||
controller : function(){
|
||||
var vm = this;
|
||||
this.suma = function(){
|
||||
return vm.a + vm.b ;
|
||||
}
|
||||
},
|
||||
|
||||
controllerAs : "sumar",
|
||||
bindToController:true
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче