Wscats / angular-tutorial

:rabbit:Some of the angular tutorial - 《Angular学习笔记》

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

angular面试题

Wscats opened this issue · comments

解释下什么是 $rootScrope 以及和 $scope 的区别
$rootScrope 页面所有 $scope 的父对象
Angular解析 ng-app 然后在内存中创建 $rootScope
带有ng-controller的div然后指向到某个controller函数。这个时候在这个controller函数中变有一个$scope对象实例

Angular Directive中restrict 中分别可以怎样设置
restrict中可以分别设置:

  • A 匹配属性
  • E 匹配标签
  • C 匹配class
  • M 匹配注释

ng-show/ng-hide与ng-if的区别
我们都知道ng-show/ng-hide实际上是通过 display 来进行隐藏和显示的。而ng-if实际上控制dom节点的增删除来实现的。因此如果我们是根据不同的条件来进行dom节点的加载确认的话,那么ng-if的性能好过ng-show

列出至少三种实现不同模块之间通信方式

  • Service
  • events,指定绑定的事件
  • 使用$rootScope

实现不同模块之间的通信方式中,events,指定绑定的事件,不是很清楚……

commented

哈哈 不错 学习中·····

老姚,我今天被问到自定义的directive怎么给别人使用