简体   繁体   中英

?^^ used in in Angular JS 1.x Component

I am working on Angular JS 1.x (I know the FW is outdated:)) where in I noted the following convention to be used much in component configuration.

require: {
      componentContoller1: '^componentContoller1',
    }, 

I understand that we asking angular to get componentContoller1's controller instantiated and bind it to a property in current component, but I also noticed following convention like

require: {
          componentContoller1: '?^^componentContoller1',
        }, 

Can someone tell me what is the difference here using ?^^ , I tried google and angular doc but could not get a clarity. Any help great and thanks.

Complete configuration or set up will be like

angular.module('moduleName').component('componentName',{
templateUrl: "path to template",
require: {
          componentContoller1: '?^^componentContoller1',
         },
controller(){ //code }
})

From the official documentation ( https://docs.angularjs.org/api/ng/service/$compile#-require- )

  • (no prefix) - Locate the required controller on the current element. Throw an error if not found.
  • ? - Attempt to locate the required controller or pass null to the link fn if not found.
  • ^ - Locate the required controller by searching the element and its parents . Throw an error if not found.
  • ^^ - Locate the required controller by searching the element's parents . Throw an error if not found.
  • ?^ - Attempt to locate the required controller by searching the element and its parents or pass null to the link fn if not found.
  • ?^^ - Attempt to locate the required controller by searching the element's parents , or pass null to the link fn if not found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM