小编ste*_*eno的帖子

Redux - 减速器与动作的关系

我是新来的反应/ redux.我试图弄清楚redux中的所有部分是如何相互作用的.给我带来麻烦的一件事是理解行动和减速器之间的关系.调用操作时,商店如何知道要使用哪个减速器?它是否完全基于动作类型名称?类型名称必须是唯一的吗?reducer将新状态对象传递给的是什么或者什么,商店还是动作?

据我了解,它是这样的:

  1. store.dispatch(action)被调用
  2. store根据操作类型查找相关的reducer
  3. Reducer克隆当前状态对象,进行更改,将其传回(某处)

reducers dispatch reactjs redux

6
推荐指数
2
解决办法
1962
查看次数

从rest api填充Vue模板组件中的表

我有一个Vue组件,我试图让rest api(使用axios)数据填充表格.其余的调用返回chrome中的有效json字符串.但是,我无法在模板中填充表格.当我运行视图时,我在其余调用中收到以下错误:

TypeError:无法设置undefined的属性'courses'

这是返回的json:

[{"CourseId":"architecture","AuthorId":"cory-house","Title":"Architecting Applications","CourseLength":"4:20","Category":"Software Architecture Test"}]

这是我的模板:

<template>
  <div class="course-list-row">
    <tr v-for="course in courses">
        <td>{{ course.CourseId }}</td>
        <td>{{ course.AuthorId }}</td>
        <td>{{ course.Title }}</td>
        <td>{{ course.CourseLength }}</td>
        <td>{{ course.Category }}</td>
    </tr>
  </div>
</template>

<script>
  import axios from 'axios'
  export default {
    name: 'course-list-row',
    mounted: function () {
      this.getCourses()
      console.log('mounted: got here')
    },
    data: function () {
      return {
        message: 'Course List Row',
        courses: []
      }
    },
    methods: {
      getCourses: function () {
        const url = 'https://server/CoursesWebApi/api/courses/'
        axios.get(url, {
          dataType: …
Run Code Online (Sandbox Code Playgroud)

vue.js vue-component axios

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

Angular 2 材质对话框:在对话框关闭时刷新父级

我正在使用 angular material 2 对话框将项目添加到列表中。我有一个包含列表(表)的组件(AuthorListComponent)。该组件有一个名为 getAuthors 的函数,它进行一个休息调用并在模板中呈现一个表格。我还有一个按钮,可以打开用于添加新项目的 angular material 2 对话框:

https://github.com/angular/material2/blob/master/src/lib/dialog/README.md

我无法弄清楚的是,当保存对话框中的项目并关闭对话框时,我希望刷新 AuthorListComponent 以便显示新添加的项目。我想我必须在某处使用事件发射器来调用 getAuthors 函数,但是对话框不使用我可以将事件附加到的指令/html 元素。

这是我的模式服务:

import { Observable } from 'rxjs/Rx';
import { AuthorComponent } from '../author/author.component';
import { MdDialogRef, MdDialog, MdDialogConfig } from '@angular/material';
import { Injectable, ViewContainerRef } from '@angular/core';

@Injectable()
export class DialogService {

    constructor(private dialog: MdDialog) { }

    public openDialog(viewContainerRef: ViewContainerRef): Observable<boolean> {
        let dialogRef: MdDialogRef<AuthorComponent>;
        let config = new MdDialogConfig();
        config.viewContainerRef = viewContainerRef;
        config.disableClose = true;
        config.width = '600px';
        dialogRef = …
Run Code Online (Sandbox Code Playgroud)

modal-dialog angular-material2 angular

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

取消删除操作 - NotifyCollectionChangedAction

我在viewmodel中使用以下代码从集合中删除项目:

UnitMeasureCollection.CollectionChanged += new NotifyCollectionChangedEventHandler(ListOfUnitMeasureCollectionChanged);

void ListOfUnitMeasureCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
    if (e.Action == NotifyCollectionChangedAction.Remove)
    {
        if (NavigationActions.DeleteConfirmation("Delete Item.", "Are you sure you want to delete this item? This action cannot be undone."))
        {
            foreach (UnitMeasureBO item in e.OldItems)
            {
                UnitMeasureBO unitMeasureBO = item as UnitMeasureBO;
                bool inUse = unitMeasureRepository.UnitMeasureInUse(unitMeasureBO.UnitMeasureValue);
                if (inUse == true)
                {
                    NavigationActions.ShowError("Cannot delete item", "This item cannot be deleted because it is used elsewhere in the application.");
                }
                else
                {
                    unitMeasureRepository.DeleteUnitMeasure(unitMeasureBO.UnitMeasureValue);
                }
            }
        }
    }
} …
Run Code Online (Sandbox Code Playgroud)

wpf datagrid mvvm inotifycollectionchanged

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

AngularJS重定向到数据保存后查看

从员工维护视图保存数据后,我尝试重定向到员工详细信息视图.我想在控制器的成功方法中做到这一点:

$scope.insertEmployee = function (employee) {
    if (employee && $scope.IsNew) {
        employeeFactory.insertEmployee(employee)
            .success(function (data) {
                // after a successful save, redirect the user to the details view
                $location.path('/employee-details/' + employee.EmployeeNumber);
                if (!$scope.$$phase)
                    $scope.$apply()
            })
            .error(function (error) {
                $scope.status = 'Unable to save the employee data: ' + error;
            });
    }
    else {
        $scope.status = 'You are missing required information!';
    }
};
Run Code Online (Sandbox Code Playgroud)

这是我的工厂:

factory.insertEmployee = function (employee) {
    url = baseAddress + "employee/insert/";
    return $http.post(url, employee);
};
Run Code Online (Sandbox Code Playgroud)

我的asp.net webapi控制器:

    [Route("api/employee/insert/")]
    public …
Run Code Online (Sandbox Code Playgroud)

redirect factory controller angularjs

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

Angular/material ui - 以编程方式选择 mat-selection-list

我有一个 mat-selection-list,我需要在组件加载时以编程方式检查特定项目。我需要检查的项目将根据 mat-list-option 的 [value] 选择。我找不到任何关于此的文档。html 非常简单:

<mat-selection-list color="primary" #suretyList formControlName="AgentAgencyAndSureties">
    <mat-list-option *ngFor="let surety of suretyNames" [value]="surety.Id">
        {{surety.SuretyName}}
    </mat-list-option>
</mat-selection-list>
Run Code Online (Sandbox Code Playgroud)

我只想检查值中具有特定surety.Id 的项目。这似乎并不难做到,但正如我所说,我找不到任何关于此的示例或良好的文档。

我使用 Angular 10 作为核心 UI 和 Material UI

angular-material angular

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

knockout.js ajax导致ASP.Net MVC

我有以下控制器:

        public JsonResult EquipmentSelect(string term)
    {
        var equipmentSearchViewModel = new EquipmentSearchViewModel
        {
            EquipmentList = iEquipmentRepository.FindBy(t => t.equipment_name.Contains(term)
                || t.equipment_id.Contains(term)),
        };

        var filteredEquipment = equipmentSearchViewModel.EquipmentList.ToList();
        var sortableData = filteredEquipment.AsQueryable();
        var jsonData = new
        {
            rows = (
                     from m in filteredEquipment
                     select new
                     {
                         equipment_id = m.equipment_id,
                         equipment_name = m.equipment_name
                     }
                  ).ToArray()
        };

        return Json(jsonData, JsonRequestBehavior.AllowGet);
    }
Run Code Online (Sandbox Code Playgroud)

和以下js文件:

$(function () {
    $('#search').click(function () {
        var searchText = $('#txtsearch').val();
        getEquipment(searchText);
    })
})

// View model declaration
var EquipmentViewModel = {
    Profiles: ko.observableArray([]) …
Run Code Online (Sandbox Code Playgroud)

ajax asp.net-mvc controller knockout.js

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