Skip to content

Commit e7259e6

Browse files
add angular specific code examples
1 parent b03c5c8 commit e7259e6

File tree

1 file changed

+7
-30
lines changed
  • src/pages/[platform]/build-a-backend/data/set-up-data

1 file changed

+7
-30
lines changed

src/pages/[platform]/build-a-backend/data/set-up-data/index.mdx

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@ Let's first add a button to create a new todo item. To make a "create Todo" API
383383

384384
</InlineFilter>
385385

386-
387-
<InlineFilter filters={["react", "angular", "javascript", "nextjs", "react-native"]}>
386+
<InlineFilter filters={["react", "javascript", "nextjs", "react-native"]}>
388387

389388
```tsx title="src/TodoList.tsx"
390389
import type { Schema } from '../amplify/data/resource'
@@ -405,7 +404,6 @@ export default function TodoList() {
405404
</div>
406405
}
407406
```
408-
409407
</InlineFilter>
410408

411409

@@ -432,12 +430,9 @@ async function createTodo() {
432430
</div>
433431
</template>
434432
```
435-
436433
</InlineFilter>
437434

438435
<InlineFilter filters={["react", "angular", "javascript", "nextjs", "react-native"]}>
439-
440-
441436
Run the application in local development mode and check your network tab after creating a todo. You should see a successful request to a `/graphql` endpoint.
442437

443438
<Callout>
@@ -448,10 +443,7 @@ Try playing around with the code completion of `.update(...)` and `.delete(...)`
448443
</InlineFilter>
449444

450445
<InlineFilter filters={["angular"]}>
451-
452-
Let's first add a button to create a new todo item. To make a "create Todo" API request, generate the data client using `generateClient()` in your frontend code, and then call `.create()` operation for the Todo model. The Data client is a fully typed client that gives you in-IDE code completion. To enable this in-IDE code completion capability, pass in the `Schema` type to the `generateClient` function.
453-
454-
```tsx title="todo-list.component.ts"
446+
```ts title="todo-list.component.ts"
455447
import { Component } from '@angular/core';
456448
import type { Schema } from '../amplify/data/resource';
457449
import { generateClient } from 'aws-amplify/data';
@@ -673,9 +665,7 @@ Creating Todo successful.
673665

674666
Next, list all your todos and then refetch the todos after a todo has been added:
675667

676-
<InlineFilter filters={["react", "angular", "javascript", "nextjs", "react-native"]}>
677-
678-
668+
<InlineFilter filters={["react","javascript", "nextjs", "react-native"]}>
679669
```tsx title="src/TodoList.tsx"
680670
import { useState, useEffect } from "react";
681671
import type { Schema } from "../amplify/data/resource";
@@ -720,7 +710,6 @@ export default function TodoList() {
720710
</InlineFilter>
721711

722712
<InlineFilter filters={["vue"]}>
723-
724713
```html title="src/TodoList.vue"
725714
<script setup lang="ts">
726715
import { onMounted, ref } from 'vue';
@@ -768,7 +757,7 @@ async function createTodo() {
768757
</InlineFilter>
769758

770759
<InlineFilter filters={["angular"]}>
771-
```tsx title="todo-list.component.ts"
760+
```ts title="todo-list.component.ts"
772761
import { Component, OnInit } from '@angular/core';
773762
import type { Schema } from '../amplify/data/resource';
774763
import { generateClient } from 'aws-amplify/data';
@@ -1064,10 +1053,11 @@ export default function TodoList() {
10641053
);
10651054
}
10661055
```
1067-
10681056
</InlineFilter>
10691057

10701058
<InlineFilter filters={["vue"]}>
1059+
You can also use `observeQuery` to subscribe to a live feed of your backend data. Let's refactor the code to use a real-time observeQuery instead.
1060+
10711061
```html title="src/TodoList.vue"
10721062
<script setup lang="ts">
10731063
import { onMounted, ref } from 'vue';
@@ -1115,26 +1105,13 @@ async function createTodo() {
11151105
</div>
11161106
</template>
11171107
```
1118-
1119-
</InlineFilter>
1120-
1121-
<InlineFilter filters={["react", "javascript", "nextjs", "react-native"]}>
1122-
1123-
Now try to open your app in two browser windows and see how creating a todo in one window automatically adds the todo in the second window as well.
1124-
1125-
<Callout>
1126-
1127-
You can also use `.onCreate`, `.onUpdate`, or `.onDelete` to subscribe to specific events. Review [Subscribe to real-time events](/[platform]/build-a-backend/data/subscribe-data) to learn more about subscribing to specific mutation events.
1128-
1129-
</Callout>
1130-
11311108
</InlineFilter>
11321109

11331110
<InlineFilter filters={["angular"]}>
11341111

11351112
You can also use `observeQuery` to subscribe to a live feed of your backend data. Let's refactor the code to use a real-time observeQuery instead.
11361113

1137-
```tsx title="todo-list.component.ts"
1114+
```ts title="todo-list.component.ts"
11381115
import { Component, OnInit } from '@angular/core';
11391116
import { CommonModule } from '@angular/common';
11401117
import { generateClient } from 'aws-amplify/data';

0 commit comments

Comments
 (0)