angular.js - $emit(,)的具体意思是什么作用呢?
PHP中文网
PHP中文网 2017-05-15 17:11:07
0
2
747

这个请求接口在success的$scope.$apply()语法后,有这段代码,具体是啥意思呢?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all (2)
伊谢尔伦

The function is to tell its parent $scope that an event has been triggered. The name of the event is boyslist, and the data is result.data

If your parent $scope is listening for this event, the callback function inside will be triggered, for example

$scope.$on('boyslist', console.log);

This will print it out

Scope Events Propagation
Scopes can propagate events in similar fashion to DOM events. The event can be broadcasted to the scope children or emitted to scope parents.

You can read this for details, and then look atScope Events Propagationthat little piece

    Ty80

    Transfer child controller data to parent controller

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!