小编Suj*_*tel的帖子

将多个模型绑定到laravel中的一个View Controller

我因为无法遵循我一直认为理所当然的某种模式而开始放弃laravel!

假设我有来自此链接的示例 https://laravel.com/docs/5.4/container#introduction

public function show($id)
{
    $user = $this->users->find($id);

    return view('user.profile', ['user' => $user]);
}
Run Code Online (Sandbox Code Playgroud)

用户模型绑定到该控制器以在视图中显示。如果我需要注入另一个模型,将其称为独立于用户模型的平面(无数据库关系)。这样我就在同一个视图中列出了他们两个。

例如,在Angular中,我可以在同一页面上创建多个组件,每个组件都有自己的独立控制器和模型。

php web laravel laravel-5.4

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

激活事件后,能否在Action Event方法中获取javafxml对象的ID?

我正在尝试编写一个小的rpg,我决定将基础知识放入fxml文档(带有其项目的MenuBar)中。因此,现在我计划在单击菜单项(字符,库存和设备)时打开一个新窗口,这样我可以显示一个额外的窗口。因此,我想将每个菜单的标题设置为与MenuItem上显示的Text等效。当然,我可以为每个菜单项添加一个额外的方法,但是我正在寻找一种可能性,可以在该菜单项中触发事件的菜单项的ID,因此可以使用其getText方法来获取标记。有人可以帮我吗?

我尝试使用“ this”访问对象,并且还考虑过使用枚举将ID连接到枚举MenuName的对象,因此我只需要在方法中放入一个开关,从而创建菜单,但这也没有实现。不能解决,因为在那里我无法检查哪个ID被解雇了。因此,对于我的程序的那部分,它没有帮助。

这是我的控制器类中的代码

public class Controller {
    @FXML
    private void menuIsClickedDefault(ActionEvent event) throws Exception {
          Stage secondStage = new Stage();
          Parent a = FXMLLoader.load(getClass().getResource("menus.fxml"));
          secondStage.setTitle(HERES_MY_PROBLEM);
          secondStage.setScene(new Scene(a, 646, 400));
          secondStage.initModality(Modality.APPLICATION_MODAL);
          secondStage.show();
    }
}
Run Code Online (Sandbox Code Playgroud)

这些是我的fxml对象:

<MenuItem fx:id="stats" mnemonicParsing="false" text="Statistics" />
<MenuItem fx:id="inv" mnemonicParsing="false" text="Inventory" />
<MenuItem fx:id="equip" mnemonicParsing="false" text="Equipment" />
Run Code Online (Sandbox Code Playgroud)

我还没有将方法集成到对象中,因为如果不解决问题就没有意义,并且我知道其余代码也可以工作,原因是设置方法类似。

javafx fxml scenebuilder

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

HTML 中的“href”值可在 Android 上打开 Gmail 应用程序

我想打开 Gmail 应用程序,而不是通过单击按钮或锚标记单击在 Chrome 浏览器中打开。

href="intent://example.com/#Intent;scheme=gm.ConversationListActivity;package=com.google.android.gm;S.browser_fallback_url=market://details?id=com.google.android.gm.ConversationListActivity;end;"
Run Code Online (Sandbox Code Playgroud)

html javascript css android jquery-mobile

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

以嵌套反应形式使用setControl

我想知道当我在另一个formBuilder组中有一个数组时,如何使用反应形式使用“ setControl”和“ get”。例如:

this.formulario = this.formBuilder.group({
  title: [this.racPessoa.title, [Validators.required]],
  description: [this.racPessoa.description, [Validators.required]],
  person: this.formBuilder.group({
    idPerson:[this.racPessoa.person.idPerson],
    name:[this.racPessoa.person.nome],
    personDocument: this.formBuilder.array([])
  }),
});
Run Code Online (Sandbox Code Playgroud)

在上述情况下,如果我想使用“标题”,则可以编写:

this.formulario.setControl('title', something);
this.formulario.get('title');
Run Code Online (Sandbox Code Playgroud)

但是当我要使用一个人内部的“ personDocument”来处理时,我不知道如何在上面写两个句子

我尝试使用:

this.formulario.setControl('person.personDocument', something);
this.formulario.get('person.personDocument')
Run Code Online (Sandbox Code Playgroud)

但这是行不通的。

angular2-forms angular2-formbuilder angular angular-reactive-forms

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