小编fus*_*sio的帖子

从AngularJS中的隔离范围/指令接收广播和调用控制器功能?

这是jsfiddle举例说明我的情况.

首先,这是使用接收维度创建指令的正确方法吗?然后,每个指令应该与其他指令隔离.因此我正在使用scope: {}.

问题是调用控制器中的函数..它似乎也没有收到广播..

我确信这是一个微不足道的问题..我是Angular的新手:)

我有一个页面,我用ng-repeat加载了许多组件:

<div ng-app="test">
    <div ng-controller="containerCtrl">
        <component ng-repeat='c in components' id="c.id" my-width="{{c.width}}" my-height="{{c.height}}">
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

控制器:

controller('containerCtrl', function ($scope) {
    $scope.components = [{ id: "c1", width: 100, height: 100 },
                        { id: "c2", width: 200, height: 100 },
                        { id: "c3", width: 300, height: 100 }];

    //in the actual controller I am using a socket provider and doing
    //socket.forward([
    //        'initPage',
    //        'refreshPage'
    //    ], $scope);
    //simulating it with a simple broadcast …
Run Code Online (Sandbox Code Playgroud)

directive angularjs angularjs-scope

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

在运行Mocha测试之前删除MongoDB数据库

如果我尝试使用after(在测试结束时)删除数据库,它可以工作.

如果我尝试以下方法:

var db = mongoose.connect('mongodb://localhost/db-test')

describe('Database', function() {

    before(function (done) {
        db.connection.db.dropDatabase(function(){
            done()
        })
    })

    ...
Run Code Online (Sandbox Code Playgroud)

它不会丢弃数据库.到底是怎么回事?我宁愿在开始测试之前删除db - 所以在测试之后我可以探索db.

testing mocha.js mongoose mongodb should.js

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

在 Cypress 测试中从 @angular/cdk 导入任何内容会破坏 Angular 13 的构建

自从更新到 Angular 13 以来,我从 @angular/cdk 导入的 Cypress 测试(主要是在 Angular 材料上使用测试工具)无法编译,并出现以下错误:

Error: Webpack Compilation Error
./node_modules/@angular/cdk/fesm2015/platform.mjs
Module not found: Error: Can't resolve '@angular/common' in 'C:\dev\workspace\exp\cypress-test\node_modules\@angular\cdk\fesm2015'
resolve '@angular/common' in 'C:\dev\workspace\exp\cypress-test\node_modules\@angular\cdk\fesm2015'
  Parsed request is a module
  using description file: C:\dev\workspace\exp\cypress-test\node_modules\@angular\cdk\package.json (relative path: ./fesm2015)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      C:\dev\workspace\exp\cypress-test\node_modules\@angular\cdk\fesm2015\node_modules doesn't exist or is not a directory
      C:\dev\workspace\exp\cypress-test\node_modules\@angular\node_modules doesn't exist or is not a directory
      C:\dev\workspace\exp\cypress-test\node_modules\node_modules doesn't exist or is not a directory
      C:\dev\workspace\exp\node_modules doesn't exist or is …
Run Code Online (Sandbox Code Playgroud)

angular cypress angular-package-format

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

使用Socket.io将消息发送到多个房间?

是否可以使用socket.io将消息发送到多个房间?

发送到1个房间:

io.sockets.in(room).emit("id", {})
Run Code Online (Sandbox Code Playgroud)

发送到N个房间:

io.sockets.in(room1, room2, roomN).emit("id", {})
Run Code Online (Sandbox Code Playgroud)

channel node.js socket.io

3
推荐指数
4
解决办法
4054
查看次数