My input isn't accepted or something is off because my code is right.
in my item-detail.component.html is this code:
<StackLayout class="nt-form chat-wrapper" >
<StackLayout id="chat-form" orientation="horizontal" class="nt-input input-field form">
<TextField [(ngModel)]="usero" width="800px" class="-rounded-lg input" hint="Nachricht" style="background-color: #ffffff;"></TextField>
<button width="120px" class="-rounded-lg fa far fas fab" (tap)="sendMessage()" style="margin-left: 15px;" text=""></button>
</StackLayout>
</StackLayout>
and my item-detail.component.ts is this code:
import { DatePipe } from "#angular/common";
import { Component, OnInit } from "#angular/core";
import { ActivatedRoute } from "#angular/router";
import { FormatListNumbered } from "#material-ui/icons";
import { RouterExtensions } from "#nativescript/angular";
import { resolveFileNameFromUrl } from "#nativescript/core";
import { connectableObservableDescriptor } from "rxjs/internal/observable/ConnectableObservable";
import { ChatService, DataChat } from "../shared/chat.service";
import { FormControl } from '#angular/forms';
import { UserService, DataUser } from "../shared/user.service";
#Component({
selector: "ItemDetail",
styleUrls: ['item-detail.component.css'],
templateUrl: "./item-detail.component.html",
providers: [DatePipe]
})
export class ItemDetailComponent implements OnInit {
usero = "";
constructor(){};
sendMessage(): void{
console.log("usero", this.usero);
}
item-detail.module.ts is this:
import { NativeScriptFormsModule } from "#nativescript/angular";
import { NativeScriptCommonModule } from "#nativescript/angular/common";
import { ItemDetailComponent } from "./item-detail.component";
import { NgModule, NO_ERRORS_SCHEMA } from "#angular/core";
#NgModule({
imports: [
NativeScriptFormsModule,
NativeScriptCommonModule
],
declarations: [
ItemDetailComponent
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class ItemDetailModule { }
and my app.module.ts is this:
import { NgModule, NO_ERRORS_SCHEMA } from "#angular/core";
import { NativeScriptFormsModule, NativeScriptModule } from "#nativescript/angular";
import { FormsModule} from '#angular/forms'
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { BrowserModule } from '#angular/platform-browser';
#NgModule({
bootstrap: [
AppComponent
],
imports: [
FormsModule,
BrowserModule,
NativeScriptModule,
NativeScriptFormsModule,
AppRoutingModule,
NativeScriptFormsModule
],
declarations: [
AppComponent
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class AppModule { }
So everythin that i should do is done. But for whatever reason it doesnt work the variable is empty.
For anyone getting on the same issue:
In the NativeScript docs is a good doc for TextField:
https://docs.nativescript.org/angular/ui/ng-components/text-field
So my textfield looks like this:
<TextField
(textChange)="onTextChange($event)"
width="800px"
class="-rounded-lg input"
hint="Nachricht"
style="background-color: #ffffff;"
></TextField>
and my ts like this:
onTextChange(args){
let textField = <TextField>args.object;
this.text = textField.text;
}
And if the Button is pressed this function is called:
sendMessage(): void{
console.log("textfield", this.text);
}
I am building a blog with multiple gatsby-source-filesystem instances.
I am trying to use gatsby-image on a page but it simply returns:
TypeError: Cannot read property 'fixed' of undefined
The image I'm trying to query is located at src/images
spirits.js
import React from "react"
import { graphql } from "gatsby"
import Img from 'gatsby-image'
import Layout from "../components/layout"
import SEO from "../components/seo"
import Paper from '../components/paper'
const SpiritsPage = ({data}) => (
<Layout>
<SEO title="Spirits" />
<Paper>
<h1>Spirits</h1>
<p>This section is still under construction.</p>
<Img fixed={data.allImageSharp.edges.node.fixed} alt />
</Paper>
</Layout>
)
export const query = graphql`
query {
allImageSharp(filter: {fluid: {originalName: {eq: "australia.png"}}}) {
edges {
node {
fixed {
...GatsbyImageSharpFixed
}
}
}
}
}
`
export default SpiritsPage
gatsby-config.js
{
resolve: `gatsby-source-filesystem`,
options: {
name: `distilleries`,
path: `${__dirname}/content/distilleries`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `posts`,
path: `${__dirname}/content/posts`
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
data.alImageSharp.edges is an array, so you can't do data.allImageSharp.edges.node. Instead, what you need to do is grab the item you want from the edges array and then do node.fixed on it. Something like the following would work: data.allImageSharp.edges[0].node.fixed
credit – goto1
ERROR Error: Uncaught (in promise): Error: Type UserProfileComponent is part of the declarations of 2 modules: AdminLayoutModule and DemoLayoutModule! Please consider moving UserProfileComponent to a higher module that imports AdminLayoutModule and DemoLayoutModule. You can also create a new NgModule that exports and includes UserProfileComponent then import that NgModule in AdminLayoutModule and DemoLayoutModule.
Error: Type UserProfileComponent is part of the declarations of 2 modules: AdminLayoutModule and DemoLayoutModule! Please consider moving UserProfileComponent to a higher module that imports AdminLayoutModule and DemoLayoutModule. You can also create a new NgModule that exports and includes UserProfileComponent then import that NgModule in AdminLayoutModule and DemoLayoutModule.
demo layout
import { NgModule, Component } from '#angular/core';
import { RouterModule } from '#angular/router';
import { CommonModule } from '#angular/common';
import { FormsModule, ReactiveFormsModule } from '#angular/forms';
import { DemoLayoutRoutes } from './demo-layout.routing';
import { DemodashboardComponent } from '../../pages/demodashboard/demodashboard.component';
import { UserProfileComponent } from '../../pages/user-profile/user-profile.component';
import { ComponentsModule } from 'app/components/components.module';
import { AddComponent } from 'app/components/add/add.component';
import { DemoRetrieveComponent } from 'app/components/demoretrieve/demoretrieve.component';
import {
MatButtonModule,
MatInputModule,
MatRippleModule,
MatFormFieldModule,
MatTooltipModule,
MatSelectModule,
MatRadioModule,
MatStepperModule,
MatListModule,
MatDatepickerModule,
MatNativeDateModule,
MatIconModule,
} from '#angular/material';
import { FusionChartsModule } from 'angular-fusioncharts';
import { AnalysisComponent } from 'app/components/analysis/analysis.component';
import { BrowserModule } from '#angular/platform-browser';
import { HttpModule } from '#angular/http';
import * as FusionCharts from 'fusioncharts';
import * as Charts from 'fusioncharts/fusioncharts.charts';
import * as FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
import { UserProfileViewComponent } from 'app/components/user-profile-view/user-profile-view.component';
import { ReportEditComponent } from 'app/components/report-edit/report-edit.component';
import { ReportDeleteComponent } from 'app/components/report-delete/report-delete.component';
import { ReportViewComponent } from 'app/components/report-view/report-view.component';
FusionChartsModule.fcRoot(FusionCharts, Charts, FusionTheme);
#NgModule({
imports: [
CommonModule,
RouterModule.forChild(DemoLayoutRoutes),
FormsModule,
MatButtonModule,
MatRippleModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
MatTooltipModule,
ComponentsModule,
MatRadioModule,
MatStepperModule,
ReactiveFormsModule,
MatListModule,
MatDatepickerModule,
MatNativeDateModule,
MatIconModule,
FusionChartsModule,
HttpModule,
],
declarations: [
DemodashboardComponent,
UserProfileComponent,
AnalysisComponent,
AddComponent,
DemoRetrieveComponent,
UserProfileViewComponent,
ReportEditComponent,
ReportDeleteComponent,
ReportViewComponent,
]
})
export class DemoLayoutModule {}
import { Routes } from '#angular/router';
import { DemodashboardComponent } from '../../pages/demodashboard/demodashboard.component';
import { UserProfileComponent } from '../../pages/user-profile/user-profile.component';
import { AddComponent } from 'app/components/add/add.component';
import { DemoRetrieveComponent } from 'app/components/demoretrieve/demoretrieve.component';
import { UserProfileViewComponent } from 'app/components/user-profile-view/user-profile-view.component';
import { AnalysisComponent } from 'app/components/analysis/analysis.component';
import { ReportEditComponent } from 'app/components/report-edit/report-edit.component';
import { ReportDeleteComponent } from 'app/components/report-delete/report-delete.component';
import { ReportViewComponent } from 'app/components/report-view/report-view.component';
export const DemoLayoutRoutes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: 'dashboard', component: DemodashboardComponent },
{ path: 'Dashboard', component: DemodashboardComponent },
{ path: 'User-Profile', component: UserProfileComponent},
{ path: 'User-Profile-view', component: UserProfileViewComponent},
{ path: 'add', component: AddComponent },
{ path: 'demoretrieve', component: DemoRetrieveComponent },
{ path: 'analysis', component: AnalysisComponent },
{ path: 'report-edit', component: ReportEditComponent },
{ path: 'report-delete', component: ReportDeleteComponent },
{ path: 'report-view', component: ReportViewComponent },
];
admin layout
import { NgModule } from '#angular/core';
import { RouterModule } from '#angular/router';
import { CommonModule } from '#angular/common';
import { FormsModule, ReactiveFormsModule } from '#angular/forms';
import { AdminLayoutRoutes } from './admin-layout.routing';
import { AdmindashboardComponent } from '../../pages/admindashboard/admindashboard.component';
import { UserProfileComponent } from '../../pages/user-profile/user-profile.component';
import { IconsComponent } from '../../pages/icons/icons.component';
import { UserAccessComponent } from 'app/pages/user-access/user-access.component';
import {
MatButtonModule,
MatInputModule,
MatRippleModule,
MatFormFieldModule,
MatTooltipModule,
MatSelectModule,
MatSlideToggleModule,
MatIconModule,
MatDatepickerModule,
MatNativeDateModule,
} from '#angular/material';
import { AdminEditUserDetailComponent } from 'app/pages/admin-edit-user-detail/admin-edit-user-detail.component';
import { UserProfileDeleteComponent } from 'app/components/user-profile-delete/user-profile-delete.component';
import { UserProfileEditComponent } from 'app/components/user-profile-edit/user-profile-edit.component';
import { UserProfileAddComponent } from 'app/components/user-profile-add/user-profile-add.component';
import { UserProfileViewComponent } from 'app/components/user-profile-view/user-profile-view.component';
import { HttpClientModule } from '#angular/common/http';
import { HttpModule } from '#angular/http';
#NgModule({
imports: [
CommonModule,
RouterModule.forChild(AdminLayoutRoutes),
FormsModule,
MatButtonModule,
MatRippleModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
MatTooltipModule,
MatSlideToggleModule,
MatIconModule,
MatDatepickerModule,
MatNativeDateModule,
ReactiveFormsModule,
HttpClientModule,
HttpModule,
],
declarations: [
AdmindashboardComponent,
IconsComponent,
UserAccessComponent,
AdminEditUserDetailComponent,
UserProfileDeleteComponent,
UserProfileEditComponent,
UserProfileAddComponent,
UserProfileViewComponent,
UserProfileComponent,
]
})
export class AdminLayoutModule {}
import { Routes } from '#angular/router';
import { AdmindashboardComponent } from '../../pages/admindashboard/admindashboard.component';
import { UserAccessComponent } from '../../pages/user-access/user-access.component';
import { UserProfileComponent } from '../../pages/user-profile/user-profile.component';
import { IconsComponent } from '../../pages/icons/icons.component';
import { AdminEditUserDetailComponent } from 'app/pages/admin-edit-user-detail/admin-edit-user-detail.component';
import { UserProfileDeleteComponent } from 'app/components/user-profile-delete/user-profile-delete.component';
import { UserProfileEditComponent } from 'app/components/user-profile-edit/user-profile-edit.component';
import { UserProfileAddComponent } from 'app/components/user-profile-add/user-profile-add.component';
import { UserProfileViewComponent } from 'app/components/user-profile-view/user-profile-view.component';
import { AdminuserService } from 'app/service/adminuser.service';
export const AdminLayoutRoutes: Routes = [
/* {
path: '',
children: [ {
path: 'dashboard',
component: AdmindashboardComponent
}]},
{ path: '', pathMatch: 'full', redirectTo: 'dashboard', component: AdmindashboardComponent },
{ path: 'Dashboard', component: AdmindashboardComponent },
{ path: 'User-Profile', component: UserProfileComponent},
{ path: 'User-Profile-delete', component: UserProfileDeleteComponent },
{ path: 'User-Profile-edit', component: UserProfileEditComponent },
{ path: 'User-Profile-view', component: UserProfileViewComponent},
{ path: 'Add-Users', component: UserProfileAddComponent },
{ path: 'User-Access', component: UserAccessComponent },
{ path: 'icons', component: IconsComponent },
{ path: 'Edit-User-Detail', component: AdminEditUserDetailComponent}
];
you can create all share module and then UserProfileComponent put it to ngmodule declarations array
#NgModule({
imports: [
CommonModule,
RouterModule,
FormsModule,
MatButtonModule,
MatRadioModule,
MatRippleModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
MatTooltipModule,
MatSlideToggleModule,
MatIconModule,
MatDatepickerModule,
MatNativeDateModule,
ReactiveFormsModule,
HttpClientModule,
HttpModule,
],
declarations: [
UserProfileComponent,
UserProfileViewComponent,
]
})
export class AllShareModule { }
then that all share module put it to AdminLayoutModule and DemoLayoutModule ngmodule imports array
i'm getting an error while i'm running my app.
my app build like this :
the app-component should navigate to the app-routes and from there to the pages-component .
the pages-component template is 'router-outlet' and it navigates to the pages-routes that is navigate between the views.
i did it like this :
Main app-component :
import { Component } from "#angular/core";
import { PagesComponent } from '~/pages/pages.component'
#Component({
selector: "ns-app",
template: "<router-outlet></router-outlet>"
})
export class AppComponent { }
Main app-routes :
import { PagesComponent } from "~/pages/pages.component";
import { LoginComponent } from "~/pages/login/login.component";
import { RegisterComponent } from "~/pages/register/register.component";
import { AuthGuard } from "~/#shared/services/auth-guard.service";
import { TaskListComponent } from "~/pages/task-list/task-list.component";
export const AUTH_PROVIDERS = [
AuthGuard
];
export const APP_ROUTES = [
{ path: "", redirectTo: "/pages", pathMatch: "full" },
{ path: "**", redirectTo: "" },
];
pages-component :
import { OnInit, Component } from "#angular/core";
import { RouterExtensions } from "nativescript-angular/router";
import { Router } from "#angular/router";
#Component({
moduleId: module.id,
selector: "pages",
template: "<router-outlet></router-outlet>"
})
export class PagesComponent implements OnInit {
constructor(private routerExtensions: RouterExtensions, private router:
Router) {
}
ngOnInit(): void {
}
}
pages-routes :
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { ModuleWithProviders } from "#angular/core";
import { PagesComponent } from "~/pages/pages.component";
import { LoginComponent } from "~/pages/login/login.component";
import { RegisterComponent } from "~/pages/register/register.component";
import { AuthGuard } from "~/#shared/services/auth-guard.service";
import { TaskListComponent } from "~/pages/task-list/task-list.component";
const PAGES_ROUTES = [
{path: "pages", component: PagesComponent, children: [
{ path: "login", component: LoginComponent },
{ path: "register", component: RegisterComponent },
{ path: "task-list", canActivate: [AuthGuard], component:
TaskListComponent },
{ path: "", redirectTo: "/task-list", pathMatch: "full" },
]
},
];
//, canActivate:[AuthGuard]
export const PagesRoutingModule: ModuleWithProviders =
NativeScriptRouterModule.forRoot(PAGES_ROUTES);
the error I've got :
The Error Screenshot
what do you think can be the problem ? am i missing something?
thank you !