小编Cha*_*kin的帖子

Angular 2 - EXCEPTION:_this.subscribe不是函数 - 自定义验证

我正在尝试实现自定义验证规则来验证是否选中了复选框.

但是我收到了一个错误

error_handler.js:46 EXCEPTION: _this.subscribe is not a function
Run Code Online (Sandbox Code Playgroud)

当我尝试添加自定义验证器时

validator.ts

 import {Control} from "angular/common";

 interface ValidationResult {
     [key: string]: any;
 }

 export class CustomValidators {

     static validateChecked(c: Control): ValidationResult {
         return (c.value);
     }
 }
Run Code Online (Sandbox Code Playgroud)

Component.ts

import {Component} from '@angular/core';

import {FormBuilder, FormGroup, Validators, FormControl} from '@angular/forms';
import {CustomValidators} from './validators.ts'

@Component({
    selector: 'wizard',
    templateUrl: './template.html',
})

/**
 * @todo - check how first select is automatically active
 * @todo - export form presets to form class
 */
export class …
Run Code Online (Sandbox Code Playgroud)

angular2-forms angular

8
推荐指数
2
解决办法
3457
查看次数

更新angular-smart-table中的行

在我的应用程序中,我通过角度智能表列出表中的用户.现在我想修改它后更新记录.我找不到任何可以在rowCollection中更改用户的函数,因此我的列表视图直接反映了这些更改.

这是我从API接收用户的服务

services.factory('Users', function($resource) {
    return $resource('/api/v1.0.0/users/:id', {id: '@id'}, {
        update: {
            method: 'PUT'
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

这是我的列表控制器,用于从我的工厂获取数据.它还具有删除功能.删除函数工作正常 - 它只是从usersRowCollection中删除一个索引.API将其从数据库中删除.

app.controller('UsersCtrl', ['$scope', '$resource', 'Users',
    function ($scope, $resource, Users) {

        // Defines how many items per page
        $scope.itemsByPage = 10;

        // Create a reference object of usersRowCollection for smart table
        $scope.usersRowCollection = Users.query();
        $scope.usersDisplayedCollection = [].concat($scope.usersRowCollection);

        /**
         * Function to send a DELETE request to the API
         * and to remove the row from the table
         * @param user  The row …
Run Code Online (Sandbox Code Playgroud)

angularjs smart-table

5
推荐指数
0
解决办法
1434
查看次数

使用gulp-webserver与代理和中间件

我正在尝试让gulp-webserver使用代理和中间件.

我的角应用程序应该在端口3000上使用gulp-webserver运行我的Laravel后端在带有URL的apache上运行:" http://backend.api/api/v1 "

现在我想在我的角度应用中重定向/代理所有请求,以'/ api'开头到'backend.api/api /'

示例:对于ajax的角度为url:'/ api/v1/users'应该转到'backend.api/api/v1/users'并从那里获取它的json数据.

sry在backend.api url前面缺少http - 但是stackoverflow不允许我在一个帖子中有超过2个链接.

我已经尝试了几个小时让它与gulp-webserver一起使用在gulp-connect上它正在使用这个设置:

gulp.task('webserver', function () {
    plugins.connect.server({
        root: paths.distDevelopFolder,
        port: 3000,
        middleware: function (connect, o) {
            return [(function () {
                var url = require('url');
                var proxy = require('proxy-middleware');
                var options = url.parse('http://backend.api/api');
                options.route = '/api';
                return proxy(options);
            })(), historyApiFallback];
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

proxy angularjs

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

标签 统计

angularjs ×2

angular ×1

angular2-forms ×1

proxy ×1

smart-table ×1