小编3gw*_*ain的帖子

如何添加循环数组中每个3的hr元素.使用Handlebarsjs?

我有一个元素数组,我将它们全部附加到我的表单元素.一切正常.但我无法在我的第三个标签上添加"hr"元素..我试过这个.

<script id="locale-template" type="text/x-handlebars-template">
        {{#each this}}
                {{#if @index % 3 === 0 }}
                    <hr/>
        {{/if}}
        <label><input type="checkbox" /> {{name}} </label>
        {{/each}}
    </script>
Run Code Online (Sandbox Code Playgroud)

但不起作用..任何人都可以建议我正确的方式...?

提前致谢

handlebars.js

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

Jquery按属性值选择不起作用 - 包含值中的空格

在我的复选框中,我正在使用选择元素使用值...为那(样本)我做这样的..

<form>
    <input type="checkbox" value="one 234" />
</form>

function doit(){
    var x = "one 234"
    $(':checkbox[value='+x+']')
    .css({border:"1px solid green"})
}

doit();
Run Code Online (Sandbox Code Playgroud)

但是不起作用..如果我删除"一个234"的值之间的空间 - 它的工作原理.如何处理这种情况..?

这是jsfiddle

jquery jquery-selectors

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

如何在javascript模块之间进行通信...?

在我的应用程序中有几个模块各自负责,这就是我有些困惑的地方..

  1. 模块之间如何通信?

  2. 如何通知或听取模块之间的决定适当的场景..?

例子:

模块一,

var MyModule1 = (function() {
  var myPrivateData = 303;
  function myPrivateFunction() {
    alert('private');
  }
  return {
    myPublicData : 42,
    myPublicFunction : function() {
      alert('public');
    }
  };
})();
Run Code Online (Sandbox Code Playgroud)

模块 2

var MyModule2 = (function() {
  var myPrivateName = privatized;
  function myPrivateFunction() {
    alert(myPrivateName) ;
  }
  return {
    myPublicData : 42,
    myPublicFunction : function() {
      alert('public');
    }
  };
})();
Run Code Online (Sandbox Code Playgroud)

我怎样才能让他们互相交流和倾听..?任何人都可以用一些小例子来澄清吗?我需要共享与 module2 共享的 privateData 和与 module1 共享的 myPrivate 名称,以防触发任何点击事件。

提前致谢!

javascript oop jquery module

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

NgSwitch - 表现出乎意料,`No provider for NgSwitch` - 异常获取

这是我的 html:

<ng-container *ngIf="col.data !== ''">
    <ng-template [ngSwitch]="col.data">
        <ng-container *ngSwitchCase="'Page'">
            <div>{{getData(data, col.data, col.dataName)}}</div>
        </ng-container>
        <ng-container *ngSwitchDefault>
            {{getData(data, col.data, col.dataName)}}
        </ng-container>
    </ng-template>
</ng-container>
Run Code Online (Sandbox Code Playgroud)

当我使用上面的方法实现 switchCase 时,得到如下错误:

No provider for NgSwitch ("<ng-template [ngSwitch]="col.data"> [ERROR ->]<ng-container *ngSwitchCase="'Page'">

像上面一样。在我使用 ngswich 之前,它运行良好。我也已经导入了通用模块..

有人帮我解决这个问题吗?

angular-directive angular angular8

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

在jquery中突出显示当前页面

我有12个html页面.单击左侧导航栏链接时会加载所有这些页面.在这里,我需要在当前链接中添加一个类,单击并加载页面.我试过这个:

$(function(){
    $('#container li a').click(function(){
        $('#container li a').removeClass('current');
        var pathname = (window.location.pathname.match(/[^\/]+$/)[0]);
        var currentPage = $(this).attr('href');

        if(currentPage==pathname){
            $(this).addClass('current');
        }
        else{
            alert('wrong');
        }

       // alert(pathname+' currentPage: '+currentPage);

    })
})
Run Code Online (Sandbox Code Playgroud)

它工作,但在页面加载,类被删除,我不知道为什么它发生..

任何帮助?

javascript regex jquery

3
推荐指数
2
解决办法
9094
查看次数

如何获取和过滤数据

在我的骨干功能中,一切正常,甚至是过滤器.但问题是,每当我点击过滤器类型并切换到另一种过滤器类型时,它就会从现有的过滤数据中过滤,而不是从服务器和过滤器中获取新的...

如果我通过我的过滤器功能添加了fetch调用,它会获取应用所有数据,而不进行过滤...我该如何解决这个问题?

我的代码:

    $(document).ready(function(){
    var school = {};

    school.model = Backbone.Model.extend({
        defaults:{
            name:'no name',
            age:'no age'
        }
    });

    school.collect = Backbone.Collection.extend({
        model:school.model,
        url:'js/school.json',
        initialize:function(){
            this.sortVar = "name"
        }
    });

    school.view = Backbone.View.extend({
        tagName:'div',
        className:'member',
        template:$('#newTemp').html(),
        render:function(){
            var temp = _.template(this.template);
            this.$el.html(temp(this.model.toJSON()));
            return this;
        }
    });

    school.views = Backbone.View.extend({
        el:$('#content'),
        events:{
            'click #newData' : 'newArrival',
            'click #showName' : 'showByName',
            'click #showAge' : 'showByAge'
        },
        initialize:function(){
            _.bindAll(this);
            this.collection = new school.collect;
            this.collection.bind('reset', this.render);
            this.collection.fetch();
            this.childViews = [];
        },
        newArrival:function(){
            this.collection.fetch(); //it works …
Run Code Online (Sandbox Code Playgroud)

backbone.js backbone-views

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

如何将数据从登录页面传递到 OAuth 2.0 然后将其取回?

我正在为我的 AngularJS 应用程序使用 OAuth 2.0。当用户单击其他应用程序之一时,我将使用如下参数重定向到我的 Angular 应用程序:

https://stic-scm-auto.snitco.com/fsHardSoft/createCase?sn=FOC0948Y1WB 
Run Code Online (Sandbox Code Playgroud)

当访问上面的 URL 时,我将向他们显示登录页面。(因为他们还没有登录)

稍后我将它们重定向到这里:

https://cloudsso-test.snitco.com/as/
Run Code Online (Sandbox Code Playgroud)

他们到达那里后,我被重定向到登录 URL:

https://sso-test.snitco.com/autho/forms/CDClogin.html
Run Code Online (Sandbox Code Playgroud)

登录成功后,它会重定向回我的应用程序的 OAuth 回调页面。

如何将createCase?sn=FOC0948Y1WB- 参数传递给上述所有网关并取回数据?

oauth oauth-2.0 angularjs

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

如何单独更新`BehaviorSubject`单值

在我BehaviorSubject的地址元素具有2属性。在此如何单独更新单个属性?

这是我的尝试:

myAddress:any = {
    "plot":32,
    "street":"D15 Road"
  }

  private address = new BehaviorSubject(this.myAddress);
  addressClass = this.address.asObservable();


  updateAddress(newAddress){
    this.address.next(newAddress);
  }
Run Code Online (Sandbox Code Playgroud)

我正在尝试这样更新:

import { Component, Input, OnInit } from '@angular/core';
import { SharedObject } from './shared.object';

@Component({
  selector: 'hello',
  template: `
    <h1>Hello {{name}}!</h1>
    <h2>City Name in Hero : {{heroName}}</h2>
    <h3>{{plotNo}}</h3>
    <button (click)="updatePlot(44)">Update Ploat </button>
  `,
  styles: [`h1 { font-family: Lato; }`]
})
export class HelloComponent  {

  @Input() name: string;

  plotNo:number;
  address:any;


  constructor(private shared:SharedObject){

  }

  ngOnInit(){
     this.shared.addressClass.subscribe((address) => {
       this.plotNo …
Run Code Online (Sandbox Code Playgroud)

angular angular5

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

无法在 Angular 7 应用程序中覆盖 Bootstrap

在 Angular 应用程序中,我试图breadcrumb通过删除分隔线来覆盖我的风格。我用https://getbootstrap.com/docs/4.2/components/breadcrumb/#example。但它不起作用。

这是我的 angular.json 文件脚本

    {
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ibo": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/ibo",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "stylePreprocessorOptions": {
                "includePaths": [
                  "node_modules/bootstrap",
                  "src/styles"
                ]
             },
            "scripts": [
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ],
            "styles": [
               "node_modules/font-awesome/css/font-awesome.min.css",
               "node_modules/bootstrap/dist/css/bootstrap.min.css",
               "src/styles/styles.scss",
            ], …
Run Code Online (Sandbox Code Playgroud)

sass twitter-bootstrap angular angular7

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

VS code,有没有办法按类型统计文件?说我需要计算项目中的“ts”文件

在我的庞大项目中,我想计算“.ts”文件的存在情况。以及“.spec.ts”文件。如何分别计算它们。“Visual Studio Code”有办法吗?只需通过文件扩展名来计算文件即可。

目前我正在尝试使用“ctl + shif+ f”但不起作用。

提前致谢。

visual-studio-code

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