小编Ba5*_*14n的帖子

父模块作为依赖项

我的应用程序有一个角度模块:

var io = angular.module('IO_Operations', []);
Run Code Online (Sandbox Code Playgroud)


该模块还有一个服务来实现输入/输出的东西:

io.service('ioService', function () {
    var dataStore = {};

    return {
        pushData: function (key, value) {
            dataStore[key] = value;
        },
        getData: function (key) {
            return dataStore[key];
        }
    };
});
Run Code Online (Sandbox Code Playgroud)


后来我想将dataStore带有JSON 的变量存储在一个文件中作为对象.

现在我有一个iframe用标签显示一些内容,你可以称之为浏览器.


为了能够进行一些设置,我想在一个iframe中完成.为了将数据保存到文件,我需要调用IO_Service,在父应用程序中

在我的iframe中我有一个模块:

var settings = angular.module("settings", []);
Run Code Online (Sandbox Code Playgroud)

用控制器

settings.controller("MyController", function ($scope) { ... }
Run Code Online (Sandbox Code Playgroud)

所以我需要为父模块声明一个依赖项来使用它ioService来调用该pushData函数.

有没有人有一些提示让我意识到这一点?

javascript iframe angularjs

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

Angular UI - Bootstrap Accordion not working/dynamic ng-include

我对手风琴有问题:

我尝试做的几乎与演示显示的相同,我有一个对象数组.每个对象都包含一个字符串,即标题标题.它还包含一个字符串,它是另一个HTML-File 的相对路径,它应该是accordion-group的内容.

$scope.groups = [{
    groupTitle: "Title1",
    templateUrl: "sites/file1.html"
}, {
    groupTitle: "Title2",
    templateUrl: "sites/file2.html"
}];
Run Code Online (Sandbox Code Playgroud)

此代码位于名为的控制器中AccordionController.在我的HTML中,我在控制器中有这个代码

<accordion>
    <accordion-group ng-repeat="group in groups" heading="{{group.groupTitle}}">
        <div ng-include="group.templateUrl"></div>
    </accordion-group>
</accordion>
Run Code Online (Sandbox Code Playgroud)

ng-include和那些东西有效,但是这些组基本上没有对点击做出反应然后打开或关闭,我也尝试添加is-open指令.使用参数我指向一个布尔数组,它改变了特定的值ng-click

烦人的事情 - 我真的不明白 - 这一切都在Plunker中有效

我也联系了

<link rel="stylesheet" type="text/css" href="styles/bootstrap.min.css" />
<script type="text/javascript" src="scripts/angular.js"></script>
<script type="text/javascript" src="scripts/ui-bootstrap-tpls-0.12.0.js"></script>
Run Code Online (Sandbox Code Playgroud)

并添加bootstrap.ui到我的模块中.

我收到错误消息:TypeError: undefined is not a function在我加载它时在控制台中.

我将不胜感激任何帮助!

angularjs angular-ui angularjs-ng-repeat angular-ui-bootstrap angularjs-ng-include

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

RedirectToAction到另一个Controller并传递参数

我是C#的新手,特别是在ASP.NET MVC中.

我有我的HomeController,它包含这个方法:

public ActionResult Error(Error error)
{
    return View(error);
}
Run Code Online (Sandbox Code Playgroud)

现在我有另一个Controller,里面有以下行:

return RedirectToAction("Error","Home", new { Error = (new Error("ErrorName","ErrorDescription"))} );
Run Code Online (Sandbox Code Playgroud)

您可能会注意到,我正在尝试将Error对象传递给另一个控制器,然后该控制器应将其传递给View.

我自己编写的Error类,没什么了不起的:

public class Error
{
    public String name {  get; private set; }
    public String description {  get; private set; }
    public int number {  get; private set; }

    public Error(String name, String description)
    {
        this.name = name;
        this.description = description;
        number = 0;
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,每当我尝试访问HomeController中的错误变量时,它就是null.我已经用谷歌搜索了一些帖子,但我不明白,为什么我的代码不起作用.没有错误,只有这个空值对象..我感谢任何帮助!:)

c# asp.net asp.net-mvc asp.net-mvc-4

6
推荐指数
1
解决办法
9560
查看次数

文件的同步散列函数

我有一个函数,它为给定的路径生成校验和

function getHash(path) {
     var fs = require('fs');
     var crypto = require('crypto');

     var fd = fs.createReadStream(path);
     var hash = crypto.createHash('sha1');
     hash.setEncoding('hex');

     fd.on('end', function () {
        hash.end();
        // *** Here is my problem ***
        console.log(hash.read()); 
     });

     fd.pipe(hash);
  };
Run Code Online (Sandbox Code Playgroud)

我想调用calcNewHash函数,以便它返回哈希,问题是,我没有找到这个的异步版本,也许有人可以帮助.

只是添加一个return语句不起作用,因为该函数在一个Listener中

后来我想将校验和添加到一个对象,所以我可以将它作为参数提供给它,但这仍然不会改变它是异步的......

javascript node.js

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

将汇编器 (8086) 命令转换为机器代码

我需要将汇编命令翻译MOV BL,[ALPHA]成 intels 8086 处理器的机器代码。因此,ALPHA 是数据段第 11 个位置的 1 字节变量,已加载到寄存器中DS

我已经翻译了MOV AL,[ALPHA]我的另一项任务。在这里,我MOV AL/AX,addr在指令集表中找到了 ,这样我就可以将整个内容翻译成1010|0000 1010|0000机器A0 10代码。

我倾向于使用MOV r/m1,r/m2指令集表,但我不是 100% 确定,因为我在选择部件时遇到了问题r/m。由于这是考试的准备,如果有人能提供帮助,我会非常高兴:)

assembly machine-code x86-16

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