0.0.1 • Published 3 years ago

angular-tiny v0.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
3 years ago

Angular-tiny

Angular-tiny是一个类AngularJS的迷你框架, 实现了双向数据绑定,模板解析, 组件化等前端框架必备的部分,同时内置了HTTP服务等模块,方便开发者.

⚠ 此项目仅作为个人探究前端框架学习的总结,不建议在生产环境中的使用

快速上手

安装

yarn add angular-tiny

实现基本的counter app

html部分

<!DOCTYPE html>
<html>
<head>
</head>
<body ng-app="myCounterApp">
  <div ng-controller="CounterController as ctrl">
    {{ctrl.counter}}
    <button ng-click="ctrl.increment()">+</button>
    <button ng-click="ctrl.decrement()">-</button>
  </div>
  <script src="../dist/angular-tiny.js"></script>
  <script src="counter.js"></script>
</body>
</html>

js部分

angular.module('myCounterApp', []).controller('CounterController', function() {
  this.counter = 1
  this.increment = function() {
    this.counter++
  }
  this.decrement = function() {
    this.counter--
  }
})

Done/Todo

  • scope继承
  • 依赖注入系统
  • Promise服务模块
  • Http服务模块
  • 指令,插值绑定及组件化
  • ngModel, ngSwitch等指令
  • 路由模块

参考资料

  • build-your-own-angularJS

  • Javascript框架设计