小编Jos*_*ebi的帖子

将ReactiveFormsModule添加到我的angular 4应用程序后,没有获得NgControl错误的提供程序

我收到此错误 - "模板解析错误:NgControl没有提供者"

 The error comes from this line of code

 --> <select (ngModel)="currencies" (ngModelChange)="showPurchase($event)" class="annka-center" name="curencies">
       <option *ngFor="let money of currencies; let i = index" (ngValue)="money" (click)="showPurchase(money)"> {{money.Currency}} </option>
 </select>
Run Code Online (Sandbox Code Playgroud)

上面的代码工作顺利,直到我将ReactiveFormsModule添加到我的应用程序.

我在这里尝试了解决方案

错误:没有NgControl Angular AOT的提供者

但这对我没有用.我正在使用Angular 4.

angular

12
推荐指数
3
解决办法
4万
查看次数

使用 expo-notifications 时,addNotificationReceivedListener 未在 expo 反应本机中接收通知

我在项目中使用 expo React Native,并且在项目中使用 expo-notifications 包。

我已将 "useNextNotificationsApi": true 添加到 android 对象下的 app.json 文件中,该文件位于 expo 对象下,因此 expo.android.useNextNotificationsApi : true。

我还在从服务器发送到 expo 服务器的消息上设置了 experienceId,我使用https://github.com/expo/expo-server-sdk-node包进行发送。

   messages.push({
               to: red_user.fcm_token,
               sound: 'default',
               title: "Stylist Response",
               body: "Stylist has agreed to fulfill the request",
               data: {
                   experienceId: "@glamcentralng/GlamCentral",
                   order: order._id,
                   stylist_response: "agreed" 
               },
          })  
Run Code Online (Sandbox Code Playgroud)

在我的 expo React Native 应用程序中,我正在使用我提到的 expo-notifications 包,并且我的类组件中有以下设置。

import * as Notifications from 'expo-notifications';

.
.
.
.

 componentDidMount() {

    //Not working at all 
    Notifications.addNotificationReceivedListener( notification => {
      console.log(notification);
      this._handleNotification(notification) …
Run Code Online (Sandbox Code Playgroud)

android react-native expo expo-notifications

6
推荐指数
0
解决办法
1812
查看次数

当父数据更改时,如何强制子组件重新加载其数据和视图

我正在使用angular4。尽管我曾经使用过Angular JS,但对它还是有点陌生​​。

我有一个具有对象数组的父组件

people: Person[]; //array of Person model
Run Code Online (Sandbox Code Playgroud)

并且在父组件中,用户可以通过其视图修改人员数组

现在,在父组件视图中有一个子组件(personComponent)像这样遍历people数组

<person *ngFor="let person of people; let i = index" [person]="person">
Run Code Online (Sandbox Code Playgroud)

子组件显示personComponent中每个人的百分比

@Input() person:Person; //person model
percent:number;

ngOnInit(){
    this.percent = this.person.percent;
}
Run Code Online (Sandbox Code Playgroud)

现在在父组件中,当将新人员添加到人员数组时,每个子组件都应具有新的百分比。

所以我在父组件中创建了一种方法,可以计算每个人的百分比

setPercent(){
  this.people.forEach((p)=>{
     p.percent = Math.round((p.value/this.total_amount)*100) //total amount is a variable in the parent component
  })
}
Run Code Online (Sandbox Code Playgroud)

现在每次添加新人员时,都会调用setPerson方法...问题是子组件不会更新其数据,并且人员数组中每个人员的百分比也不会更新。

我尝试在子组件person变量上使用ngOnChanges,但是它没有更新子组件数据,因此子组件视图也没有更改。我该怎么办。

javascript arrays angular

5
推荐指数
1
解决办法
1万
查看次数

启动supervisorctl会对laravel队列工作进程发出ERROR(spawn错误)

所以我安装了主管,它似乎正在运行.我在/etc/supervisor/conf.d/laravel-worker.conf中为队列工作者放置了我的配置文件

它看起来像这样

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html queue:work database --sleep=3 --tries=2 --daemon
autostart=true
autorestart=true
numprocs=4
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/laravel.log
Run Code Online (Sandbox Code Playgroud)

我的supervisord.conf看起来像这样

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0775                       ; sockef file mode (default 0700)
chown=root

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
 ; added by defining them …
Run Code Online (Sandbox Code Playgroud)

linux ubuntu multithreading supervisord

3
推荐指数
3
解决办法
2万
查看次数

将数据传递到角度4的自定义组件

我有一个带选择器的自定义组件如何在角度4中传递数据以在其模板中显示数据.喜欢

<my-component data="shirts"></my-component>
Run Code Online (Sandbox Code Playgroud)

在我的组件模板中

<h5>{{data.size}}</h5>
Run Code Online (Sandbox Code Playgroud)

不确定如何在角度4中将数据从父组件传递到子组件.

javascript angular

1
推荐指数
1
解决办法
851
查看次数

RecyclerView内容不使用片段父级的全宽度

所以我有一个片段内的recyclelerview,当内容加载到recyclerview时,它不占用屏幕的整个宽度.奇怪的是,我将这个代码用于另一个项目实际上是相同的并且没有问题.

片段布局是这样的

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/windowBackground"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.dishesteam.dishes.activities.HomeActivity">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/coordinator">

        <android.support.v4.widget.SwipeRefreshLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/swipeContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingTop="4dp"
            android:paddingBottom="4dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="vertical"
                android:id="@+id/latest_recycler">

            </android.support.v7.widget.RecyclerView>

        </android.support.v4.widget.SwipeRefreshLayout>

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/add_dish_fab"
        app:srcCompat="@drawable/ic_add_black_24dp"
        app:fabSize="normal"
        app:backgroundTint="@color/colorAccent"
        android:clickable="true"
        android:layout_margin="16dp"
        android:layout_gravity="bottom|end"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"/>

</android.support.design.widget.CoordinatorLayout>

<ImageView
    android:id="@+id/trending_img"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/ic_trending_up_black_24dp"
    android:layout_centerInParent="true"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="20dp"
    android:text="Nothing here at the moment"
    android:textSize="16sp"
    android:id="@+id/empty_text"
    android:layout_below="@+id/trending_img"
    android:layout_centerHorizontal="true"
    android:textColor="@color/ColorDarkGrey" />
Run Code Online (Sandbox Code Playgroud)

recyceler的各个项目的布局是

 <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/textColorPrimary"
app:cardCornerRadius="4dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp">

<LinearLayout …
Run Code Online (Sandbox Code Playgroud)

xml android android-layout android-fragments android-recyclerview

0
推荐指数
1
解决办法
592
查看次数

如何使用 PHP 启用 CORS

我有一个 Angular 4 应用程序与驻留在 WAMP(www 文件夹)上的 php 脚本通信,它们都在我的本地计算机上。当我点击脚本时,我在浏览器中记录了此错误。

No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost:4200' is therefore not allowed access. 
The response had HTTP status code 404.
Run Code Online (Sandbox Code Playgroud)

我知道这是因为我试图从本地主机访问本地主机,所以出现了这个问题。

我读了一些书,看来我需要从 wamp 服务器修复它。不知道如何在 wamp 上做到这一点。

php wamp cors

0
推荐指数
1
解决办法
2万
查看次数