1# FA模型绑定Stage模型ServiceExtensionAbility 2 3 4本文介绍FA模型的三种应用组件如何绑定Stage模型的ServiceExtensionAbility组件。 5 6 7## PageAbility关联访问ServiceExtensionAbility 8 9PageAbility关联访问ServiceExtensionAbility和PageAbility关联访问ServiceAbility的方式完全相同。 10 11 12```ts 13import featureAbility from '@ohos.ability.featureAbility'; 14 15let want = { 16 bundleName: "com.ohos.stage", 17 abilityName: "com.ohos.stage.ServiceExtensionAbility" 18}; 19 20let faConnect = { 21 onConnect:function (elementName, proxy) { 22 console.info("Faconnection onConnect called."); 23 }, 24 onDisconnect:function (elementName) { 25 console.info("Faconnection onDisconnect called."); 26 }, 27 onFailed:function (code) { 28 console.info("Faconnection onFailed code is: " + code); 29 } 30}; 31let connectionId = featureAbility.connectAbility(want, faConnect); 32``` 33 34 35## ServiceAbility/DataAbility关联访问ServiceExtensionAbility 36 37ServiceAbility/DataAbility关联访问ServiceExtensionAbility和ServiceAbility/DataAbility关联访问ServiceAbility的方式完全相同。 38 39 40```ts 41import particleAbility from '@ohos.ability.particleAbility'; 42 43let want = { 44 bundleName: "com.ohos.stage", 45 abilityName: "com.ohos.stage.ServiceExtensionAbility" 46}; 47 48let faConnect = { 49 onConnect:function (elementName, proxy) { 50 console.info("Faconnection onConnect called."); 51 }, 52 onDisconnect:function (elementName) { 53 console.info("Faconnection onDisconnect called."); 54 }, 55 onFailed:function (code) { 56 console.info("Faconnection onFailed code is: " + code); 57 } 58}; 59let connectionId = particleAbility.connectAbility(want, faConnect); 60``` 61