小编Har*_*mer的帖子

鼠标移出不适用于所有方向

HTML

<!--DASHBOARD-->
   <li class="always_show">
      <span class="menu_large_item" style="display: none;">
          <a href="/xyz/dashboard">
             <div class="ribbon-body-prof-menu">Dashboard</div>
          </a>
      </span>
      <a class="menu_small_item" href="/dashboard"> V </a>
    </li>
 <!--DASHBOARD-->


<!--PROFILE -->
    <li class="always_show" id="profile_menu_item">  
        <span class="menu_large_item" style="display: none;">
            <a href="/xyz/profile/iprofile/id/3">
                <div class="ribbon-body-prof-menu"> Profile</div>
            </a>
 <!--PROFILE -->
        </span>
        <a class="menu_small_item" class="selected" href="/profile/iprofile/id/3">

<!-- <img src="http://localhost/xyz/public/images/icon-industries.png" alt="Profile" title="Profile" width="12" height="15"> -->
                    N
        </a>
     </li>
Run Code Online (Sandbox Code Playgroud)

现在我希望当我将鼠标悬停在 上时menu_small_item,该menu_large_item部分会显示,当我将鼠标移出 时menu_small_itemmenu_large_item部分会隐藏。同样的事情正在发生,但在我的 html 中的最后一项的情况下,当我从下方取出鼠标时,什么也没有发生。

jQuery:

    $('li.always_show, a.menu_small_item').mouseover(function(){
        $(this).siblings('li.always_show span.menu_large_item').show();
    $(this).siblings('span').children('a').children('div.ribbon-body-prof-menu').show();
});
$('li.always_show span.menu_large_item, .ribbon-body-prof-menu').mouseout(function(){
    $(this).hide();
    $('li.always_show span.menu_large_item').hide(); …
Run Code Online (Sandbox Code Playgroud)

html jquery mouseover mouseout

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

如何在角度单元测试中使用debugeElement访问nativeElement属性

我想编写一个简单的单元测试,以检查当某些值为null或为空时按钮是否被禁用。

以下是我的规格文件:

测试规范

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import 'reflect-metadata';
import { Component,
         DebugElement,
         ViewChild }
         from  "@angular/core";

import {By} from "@angular/platform-browser";
import { FormsModule } from '@angular/forms';
import { HttpClientModule, HttpClient } from '@angular/common/http';

import { ListCommentsComponent } from './list-comments.component';
import {CommentsDataService} from '../../services/comments/comments-data.service'








describe('ListCommentsComponent', () => {



  let component: ListCommentsComponent;
  let fixture: ComponentFixture<ListCommentsComponent>;
  let debugElement:DebugElement;
  let htmlElement:HTMLElement;
  let addCommentBtn:DebugElement;


  beforeEach(async(() => {
    TestBed.configureTestingModule({

      imports: [ FormsModule, HttpClientModule],

      declarations: [ ListCommentsComponent ],

      providers:[{provide: CommentsDataService}],
     // providers:[HttpClientModule, …
Run Code Online (Sandbox Code Playgroud)

angular angular-unit-test

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

如何在角度日历周视图中使用 ng-template 以不同颜色显示某些日期的时间

我正在使用mattlewis Angular 日历来为我的项目实现周视图。我需要用不同的背景颜色显示一周中的特定时间。

我找不到输入或其他方式(使用 ng-template)来以不同的背景颜色在周视图中渲染特定单元格。

我想要这样的东西,其中周视图中特定时间的背景以不同的颜色显示。

在此输入图像描述

需要建议/帮助。

谢谢。

请通过此stackblitz 演示提出更改建议。

angular angular-calendar

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

如何在 android studio 模拟器中禁用 google chrome 的 CORS?

我正在使用端口转发在 android studio 模拟器中运行我的本地主机 Web 应用程序。但从服务器我收到后端 API 的 CORS 错误。我使用 CORS 禁用扩展或通过打开禁用安全标志的 google chrome 解决了桌面上的问题。如何在移动设备或 android studio 模拟器的 google chrome 中禁用 CORS?

same-origin-policy android-studio

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

如何使用 ng-packagr 将 Angular 库的 scss 添加到捆绑包?

我正在尝试创建基于 Angular(ng 11) 库的 scss 主题,我将通过私有 npm 注册表在单独的项目中使用该库。现在我正在尝试将全局 scss 文件添加到我的库中并将其与我的库捆绑在一起。

我想要的是:

假设我将我的scss保存在projects/my-lib/src/styles/_material.scss中:

// Import library functions for theme creation.
@import '~@angular/material/theming';

// Include non-theme styles for core.
@include mat-core();

// Define your application's custom theme.
$primary: mat-palette($mat-indigo);
$accent: mat-palette($mat-pink, A200, A100, A400);
$theme: mat-light-theme($primary, $accent);

// Include theme styles for Angular Material components.
@include angular-material-theme($theme);
Run Code Online (Sandbox Code Playgroud)

Angular 应用程序和库的文件夹结构

我希望我的捆绑包(库包)包含此 scss,以便在安装此库应用程序后可以将其导入到其全局 style.scss 文件中。

项目/my-app/src/style.scss

@import 'my-lib/_material.scss'
Run Code Online (Sandbox Code Playgroud)

我做了什么:

我从角度管理库中的资产中遵循了此文档

库 package.json (为了简单起见,我现在将 scss 文件保留在 src 文件夹之外):

{
  "$schema": "./node_modules/ng-packagr/package.schema.json",
  "name": "ui-sdk",
  "version": "0.0.1",
  "ngPackage": …
Run Code Online (Sandbox Code Playgroud)

angular-material angular angular-library ng-packagr

5
推荐指数
2
解决办法
6819
查看次数

推送器如何仅向选定的客户端发送数据

我最近在我的 PHP laravel 项目中使用了 pusher,它运行良好。我对 pusher 的了解是,它是我们的服务器和客户端之间的实时层,并创建到我们的客户端浏览器的 Web 套接字连接。我使用以下教程在我的应用程序中设置推送器:

推送器与 Laravel 的集成

我使用 pusher 为我的 Web 应用程序创建的内容:

1.我创建了一个通知功能。当一个用户向数据库添加一些数据时,说当一个用户开始关注其他用户时,会触发一个事件,该事件将数据发送到特定频道,说“通知频道”,在我的 js 代码中,我已经订阅了这个频道。为此,我写了以下代码行:

//instantiate a Pusher object with our Credential's key
    var pusher = new Pusher('68fd8888888888ee72c', {
        encrypted: true
    });

    //Subscribe to the channel we specified in our Laravel Event
    var channel = pusher.subscribe('notification-channel');

    //Bind a function to a Event (the full Laravel class)
    channel.bind('App\\Events\\HelloPusherEvent', addMessage);
Run Code Online (Sandbox Code Playgroud)
  1. 通过使用 addMessage() 函数,我可以显示一些数据。现在我已经在客户端进行了检查,以便仅当登录用户打算通过编写简单的 if 条件来接收此消息时。因为我已经在 App\Events\HelloPusherEvent 的数据中发送了预期用户的 id,所以我使用这个 Id 只向特定用户显示 msg。

但我认为这不是将推送器用于通知或任何其他功能的正确方法。进一步在我的项目中,我想使用 pusher 在用户的新闻提要上显示新的新闻提要而无需刷新页面,显然很少有用户会根据发布该新闻帖子的人看到这些帖子。

但是,如果客户端的条件停止显示数据,我将如何以不需要实施的方式使用推送器。在这里,我担心的是,如果我将继续向所有活动客户端发送数据,并设置 if 条件来过滤最终会降低我的应用程序的数据。 …

pusher

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

获取 json_encode(): 类型不受支持,编码为 null

我正在使用 json_encode() 发送我的响应的网络服务。它适用于每个 web 服务,但我得到json_encode(): type is unsupported, 仅对于以下代码编码为 null

public function getjobdetailsAction()
    {
        $this->_helper->layout ()->disableLayout ();
        $this->_helper->viewRenderer->setNoRender ( true );

        $handle = fopen ( 'php://input', 'r' );
        $jsonInput = fgets ( $handle );

        $params = Zend_Json::decode ( $jsonInput );


        if($params['user_id'] != "" && $params["job_id"] != "")
        {
            $job_id = $params["job_id"];
            $jobObj=Extended\job::getRowObject( $job_id );
            //check if job obj exist only then send job array to view.
            if($jobObj)
            {
                $job_detail_r = array();
                $job_detail_r['job_id'] = $job_id;
                $job_detail_r['job_created_by'] = $jobObj->getIlookUser()->getId(); …
Run Code Online (Sandbox Code Playgroud)

json zend-framework

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

如何在forloop angular 7中使用observable订阅

我有一个数组用户:

[0: {id:123, firstname:'xyz', lastname:'abc'}, 1:{id:456, firstname:'foo', lastname:'bar'}, 3:{id:567, firstname:'bar', lastname:'baz'}]
Run Code Online (Sandbox Code Playgroud)

我必须循环遍历此数组并调用服务API以获取用户约会.

方法1 ,我觉得这不是最佳实践,但解决问题

let userAppointments = []
  for (let user of this.users) {

    this._service
      .getUsersAppointments(
        {
          date: this.todayDate,
          id: user.id
        },
        this.token
      )
      .subscribe(res => {

       // Modifying array as per requirements-----

        userAppointments.push({
          id: user.id,
          name: `${user.firstname} ${user.lastname}`,
          appointments: res
        });
      });

  }

  this.appointments = userAppointments 
Run Code Online (Sandbox Code Playgroud)

方法2:使用forkJoin

问题:当我最终得到所有呼叫的响应时,我无法访问用户的名字和姓氏.我需要在我的最终数组this.appointments中的那些细节,即在我分配的地方调用subscribe之后res to this.appointments

        forkJoin(
    this.users
      .map(res =>
        this._service.getUsersAppointments(
          {
          date: this.todayDate,
          id: res.id

          },
          this.token
        )
      )
      .map(response => …
Run Code Online (Sandbox Code Playgroud)

angular angular-observable angular7

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

链3个或更多相关可观察物

我知道这个问题以前有人问在这里。但是接受的解决方案不适用于我,或者我无法很好地理解它。

我正在使用ng-7,我有一个简单的用例:

我有2个API,第2个取决于1st的响应。我订阅第一个API的结果,然后使用管道订阅第二个API的结果。

我的代码如下所示;

this._SomeService
        .addUserToDb(payload)
        .pipe(
          map(res => res),
          mergeMap(db1Response =>
            this._SomeService.addUserToDb2(db1Response
            )
          ),
          catchError(errodb1 => {

            return Observable.throw(new 
            Error(errorSso));
          })
        )
        .subscribe(
          resDb2 => {
              // Here I get response of addUserToDb2
          },
          errDb2 => {


          }
        )
Run Code Online (Sandbox Code Playgroud)

现在,在订阅第二个API响应之前,我想订阅另一个可观察的说法:

this._tokenService.getToken.pipe(

并希望在服务2中使用它的响应。这样:

API1 =>令牌=> API2

请建议如何实施。

更新:

我尝试实现,以下是我的实现:

  this._service.addUserToDB1(payload).pipe(
          map(resp => this.resDB1 = resp) // Adding to global variable because I need this response while subscribing to DB2 service.
          ,mergeMap(resdb1=>this._tokenService.getToken.pipe(
            mergeMap(token => this._service.addUserToDb2(
              this.resDB1,
              this.organizationId,
              this.practitionerId, …
Run Code Online (Sandbox Code Playgroud)

observable rxjs-pipeable-operators rxjs6 angular7

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

如何存储和使用角管结果在 html 文件中添加 ngClass

我在做什么:

html文件

 <div *ngFor='let result of results'>
    <div [ngClass]='{"myclass": someArray | inArray:result.id}'>
    </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

.ts 文件:

someArray = [1, 2, 3]

results = [
{id:1, name:'abc'},
{id:2, name:'xyz'},
{id:4, name:'pqr'}]
Run Code Online (Sandbox Code Playgroud)

结果:我从来没有被分配过班级。

如何使用“as”将管道结果存储在html文件中以在ngClass中使用它?

inArray (pipe):Pipe 根据数组中是否存在值返回 true 或 false。

参考Angular 2 根据管道结果添加样式

更新1:

inArray (pipe):Pipe 根据数组中是否存在值返回 -1 或索引值。

更新2: 堆栈闪电战

angular-pipe angular

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