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'm using React Active with Redux on Expo and tried to run my project on Android and getting below error:
enter image description here
Versions:
Expo: 36.0.0
React: 16.9.0
React-Native: 36.0.0 SDK
Redux: 4.0.2
React-Redux: 5.1.1
App.js
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Provider } from 'react-redux';
// import Store from './src/redux/Store';
import configureStore from './src/redux/Store';
import AppNavigator from './src/navigation/AppNavigator'
const store = configureStore();
export default function App() {
return (
<Provider store={store}>
<AppNavigator></AppNavigator>
</Provider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
=============================================
AppNavigation.js
import React from 'react';
import { createStackNavigator } from 'react-navigation-stack';
import Products from '../screens/Products';
import Checkout from '../screens/Checkout';
import Receipt from '../screens/Receipt';
import themes from '../styles/theme.style';
const AppNavigator = createStackNavigator({
Products: {
screens: Products
},
Checkout: {
screens: Checkout
},
Receipt: {
screens: Receipt
}
}, {
navigationOptions: {
headerStyles: {
backgroundColor: themes.BACKGROUND_COLOR,
paddingHorizontal: 10,
},
headerTintColor: '#fff'
}
}
);
export default AppNavigator;
========================================================
Product.js
import React, { Component } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { connect } from 'react-redux';
import Product from '../components/Product';
import { addToCart } from '../redux/actions/CartActions';
import { fetchProducts } from '../redux/actions/ProductAction';
import Logo from '../components/Logo';
import Cart from '../components/Cart';
class Products extends React.Component {
static navigationOptions = ({navigation}) => {
return {
headerTitle: 'Products',
headerLeft: <Logo navigation={navigation}/>,
headerRight: <Cart navigation={navigation}/>
}
}
constructor(props) {
super(props);
}
componentWillMount = () => {
this.props.fetchProducts();
}
addItemsToCart = (product) => {
this.props.addToCart(product);
}
render() {
const { products, navigation } = this.props
return (
<View style={styles.container}>
<View style={styles.body}>
<FlatList
data={products}
renderItem={({item}) => <Product item={item} addItemsToCart={this.addItemsToCart} product={item}/>}
keyExtractor ={(item) => item.id}
ItemSeparatorComponent= {()=> <View style={{height:0.5, backgroundColor:'#34495e90'}}/> }/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
body: {
flex: 1,
justifyContent: 'center'
}
});
const mapStateToProps = (state) => ({
products: state.products.items
})
export default connect(mapStateToProps, {addToCart,fetchProducts})(Products);
I don't know wat is wrong here, I tried with multiple options but no luck. Any suggestions will be appreciated.
Run command:
expo-cli start
Check where you are importing from.
import {createStackNavigator } from 'react-navigation/stack';
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
This is my dashboard.module.ts
import { NgModule } from '#angular/core';
import { CommonModule } from '#angular/common';
import {JwtModule} from '#auth0/angular-jwt';
import {AuthService} from '../services/auth.service';
import {dashboardComponent} from './dashboard.component';
import { foodPollComponent } from '../modules/foodPoll/foodPoll.component';
import { dashboardModuleRoutingModule } from './dashboard.routing.module';
#NgModule({
imports: [
CommonModule, dashboardModuleRoutingModule
],
declarations: [
dashboardComponent,
foodPollComponent
],
providers: [JwtModule, AuthService]
})
export class dashboardModule { }
This is my dashboard.routing.module.ts
import { NgModule } from '#angular/core';
import { Routes,
RouterModule } from '#angular/router';
import { dashboardComponent } from './dashboard.component';
import { foodPollComponent } from '../modules/foodPoll/foodPoll.component';
const routes: Routes = [
{
path: 'dashboard',
component:dashboardComponent
},
{
path: 'dashboard/:id',
component: dashboardComponent,
children: [
{
path: 'foodPoll',
component: foodPollComponent,
outlet: "details"
}
]
}
];
#NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class dashboardModuleRoutingModule {}
This is my dashboard.component.html
<div class="dashboard">
<header>Random header text</header>
<router-outlet name="details"></router-outler>
</div>
But when I change from localhost:4200/dashboard to localhost:4200/dashboard/foodPoll, nothing renders in the router outlet view. The view still remains the same as dashboard page.
Where I am doing wrong? Any help would be appreciated.
Thanks
path: 'dashboard/:id',
component: dashboardComponent,
children: [
{
path: 'foodPoll',
component: foodPollComponent,
outlet: "details"
}
]
dashboardComponent would be on url: "dashboard/...anything.../"
foodPollComponent would be on url: "dashboard/...anything.../foodPoll"
:id - is dynamic parameter for dashboardComponent