小编Jav*_*aKB的帖子

AngularJS [$ injector:unpr]未知的提供者

我试图将服务注入控制器,我收到以下错误:

Error: [$injector:unpr] Unknown provider: employeeServiceProvider <- employeeService
http://errors.angularjs.org/1.3.0-beta.17/$injector/unpr?p0=employeeServiceProvider%20%3C-%20employeeService
    at http://localhost:9082/angularJSDemo/js/lib/angular.js:78:12
    at http://localhost:9082/angularJSDemo/js/lib/angular.js:3894:19
    at Object.getService [as get] 
Run Code Online (Sandbox Code Playgroud)

这是代码的plunker.任何帮助,将不胜感激.

angularjs angularjs-service

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

Blazor:基于另一个字段的自定义验证

我正在尝试根据表单上的另一个字段在 Blazor 中构建自定义验证器。要求是当用户选中“接收短信”复选框时强制输入电话号码。我用谷歌搜索了很多,但只能找到验证空字符串或某些硬编码字符串的自定义验证器。有没有办法可以根据 Blazor 中另一个字段的值验证一个字段?

电话号码验证器:

public class PhoneNumberValidaton : ValidationAttribute
{
    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        if (value == null)
        {
            return new ValidationResult("Phone Number is mandatory if you want to receive text messages", new[] { validationContext.MemberName });
        }

        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

模型:

public class UserModel
{
    public int Id { get; set; }

    [Required]
    [Display(Name = "First Name")]
    public string FirstName { get; set; }

    [Required]
    [Display(Name = "Last Name")]
    public string …
Run Code Online (Sandbox Code Playgroud)

blazor blazor-server-side blazor-webassembly

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

使用 Hapi 18.1 延迟响应

如何使用Hapi 18.1设置响应延迟,如果 API 响应缓慢,我想看到沙漏旋转。对于我使用的早期版本,setTimeout()如下所示。

server.route({
    method: 'GET',
    path:'/hello',
    handler: (request, h) => {
       setTimeout(() => reply('Hello World!'), 1000);
    }
});
Run Code Online (Sandbox Code Playgroud)

但是 v18.1 抛出错误

server.route({
    method: 'GET',
    path:'/hello',
    handler: (request, h) => {
       setTimeout(() => h.response('Hello World!'), 1000);
    }
});
Run Code Online (Sandbox Code Playgroud)

错误

Debug: internal, implementation, error
    Error: get method did not return a value, a promise, or throw an error
    at module.exports.internals.Manager.execute (C:\Users\javakb\workspace\node_modules\hapi\lib\toolkit.js:48:29)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async Object.internals.handler (C:\Users\javakb\workspace\node_modules\hapi\lib\handler.js:46:20)
    at async exports.execute (C:\Users\javakb\workspace\node_modules\hapi\lib\handler.js:31:20)
    at async Request._lifecycle (C:\Users\javakb\workspace\node_modules\hapi\lib\request.js:312:32) …
Run Code Online (Sandbox Code Playgroud)

hapijs

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