Is not a function #1913
Answered
by
maarten-mald-digital
maarten-mald-digital
asked this question in
Q&A
-
Methods from my Models not working. I am on Nuxt 3 and using the comp API. models/Project.ts
in my component edit.vue
isMotion/isMotion()/myTest/myTest are not working. My feeling is that it is not recognized as a "Project" model. I checked the docs/chatgpt but couldnt solve it. |
Beta Was this translation helpful? Give feedback.
Answered by
maarten-mald-digital
Jul 29, 2024
Replies: 1 comment 2 replies
-
Hi,
i think you need to define your function as static to work that way. Have you tried out?
Best,
Gregor
…________________________________
Von: maarten-mald-digital ***@***.***>
Gesendet: Sonntag, 28. Juli 2024 17:48
An: CodeDredd/pinia-orm ***@***.***>
Cc: Subscribed ***@***.***>
Betreff: [CodeDredd/pinia-orm] Is not a function (Discussion #1913)
Methods from my Models not working. I am on Nuxt 3 and using the comp API.
In my models/Project.ts
`
get myTest(): string {
return 'test';
}
isMotion(): string {
return 'test';
}
`
in my component edit.vue
`
<script lang="ts" setup> import Project from '@/models/Project'; import { ProjectRepository } from '@/repositories/ProjectRepository'; const { id: projectId } = useRoute().params; const project = computed(() => useRepo(Project).find(projectId)); onMounted(() => { setTimeout(() => { console.log('mounted'); console.log(project.isMotion); console.log(project.isMotion()); console.log(project.myTest); console.log(project.myTest()); }, 2000); }); </script>
`
isMotion/isMotion()/myTest/myTest are not working.
Screenshot.2024-07-28.at.17.43.08.png (view on web)<https://github.com/user-attachments/assets/59a6e482-152f-4b47-84ea-a273797e42c1>
My feeling is that it is not recognized as a "Project" model. I checked the docs/chatgpt but couldnt solve it.
—
Reply to this email directly, view it on GitHub<#1913>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABT6RUO6BWH7XAJL5TRERVTZOUHGDAVCNFSM6AAAAABLS463ACVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWHE4DKOJVGY>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
defining as static only works when i am using Project (as a class).
My mistake was not using .value (composition api). So project.value.isMotion();
Thanks for the fast reply!