Skip to content

angular面试题 #26

@Wscats

Description

@Wscats

解释下什么是 $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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions