构建器.io 角 SDK
这是Builder的"Gen2 Angular SDK".
框架版本
这个 peerDependencies 许可 角核和常见。此安装范围没有确定一个积极支持的最小值;参见 框架版本矩阵。 。 。 .
开始
npm install @builder.io/sdk-angular
要使用SDK,你必须:
- 使用
fetchOneEntry: 您可以在这里看到如何使用它 https://www.builder.io/c/docs/content-api (中文(简体) )。 。 。 . - 将数据传递给
Content组件。 以下是一个简化的例子,显示您将如何同时使用:
import { Component } from '@angular/core';
import { Content, fetchOneEntry, type BuilderContent } from '@builder.io/sdk-angular';
@Component({
selector: 'app-catchall',
standalone: true,
imports: [Content],
template: `
@if (content) {
<builder-content [model]="model" [content]="content" [apiKey]="apiKey"></builder-content>
} @else {
<div>404 - Content not found</div>
}
`,
})
export class CatchAllComponent {
apiKey = 'YOUR_API_KEY';
model = 'page';
content: BuilderContent | null = null;
async ngOnInit() {
const urlPath = window.location.pathname || '';
const content = await fetchOneEntry({
apiKey: this.apiKey,
model: this.model,
userAttributes: {
urlPath,
},
});
if (!content) {
return;
}
this.content = content;
}
}
微缩
此 SDK 是由 微缩。要看到Mitosis源代码,请去 这里。 。 。 .
特性支持
看SDK的状态 这些表格。 。 。 .
获取
此套件使用抓取 。 见 这些文件 更多信息.
版本支持
此 SDK 支持角版本 >=17.3.0。 。 。 .