首页 \ 问答 \ Angularjs:将对象传递给状态(Angularjs: passing an object params to state)

Angularjs:将对象传递给状态(Angularjs: passing an object params to state)

我想将一个物体传递给一个州。 我是这样做的:

.state('options', {
    url: "/options?current_task",
    views: {
      "middle": {
        templateUrl: "/games/options.html"
      }
    }

以下是我称之为:

$state.go("options", {current_task: task});

但是它没有传递一个对象,而是传递了一个String“Object Object”我做错了什么?


I'd like to pass an object to a state. Here is how I did it:

.state('options', {
    url: "/options?current_task",
    views: {
      "middle": {
        templateUrl: "/games/options.html"
      }
    }

And here is how I call it:

$state.go("options", {current_task: task});

But instead of passing an object, it passed a String "Object Object" What did I do wrong?


原文:https://stackoverflow.com/questions/20635430
更新时间:2022-05-13 14:05

最满意答案

你写:

sample ar[4];
ar[4] = { 
    (1,2),
    (3,4),
    (5,6),
    (7,8) 
};

数组初始化程序的语法(仅在ar初始化期间有效)是:

sample ar[4] = { 
    {1,2},
    {3,4},
    {5,6},
    {7,8} 
};

C11(n1570),§6.7.9初始化

initializer:   
    assignment-expression 
    { initializer-list } 
    { initializer-list , }

此外, 缩写对于编写可读代码很重要。


You have written:

sample ar[4];
ar[4] = { 
    (1,2),
    (3,4),
    (5,6),
    (7,8) 
};

The syntax of the array initializer (only valid during the initialization of ar) is:

sample ar[4] = { 
    {1,2},
    {3,4},
    {5,6},
    {7,8} 
};

C11 (n1570), § 6.7.9 Initialization

initializer:   
    assignment-expression 
    { initializer-list } 
    { initializer-list , }

Also, indentation is important to write readable code.

相关问答

更多
  • 你写: sample ar[4]; ar[4] = { (1,2), (3,4), (5,6), (7,8) }; 数组初始化程序的语法(仅在ar的初始化期间有效)是: sample ar[4] = { {1,2}, {3,4}, {5,6}, {7,8} }; C11(n1570),§6.7.9初始化 initializer: assignment-expression { initializer-list ...
  • 首先,由于已经从STRUCT.h完成,所以没有必要保护包含main的包含 所以,而不是在主 #ifndef STRUCT_H #include "struct.h" #endif 直接使用(在主要的.h是应该有它已经做了保护的那个,不需要做两次) #include "struct.h" 现在回到你的代码,你遇到的问题是你没有修改函数中的结构,这意味着rows [0] .posX = 1; 将永远不会执行 这应该工作: #include "struct.h" int main(void) { ...
  • 查看对结构元素的访问: typedef struct t_element { char eleID; int size; int color; }Element; typedef struct t_Menu { char IDmenu; char elementNumber; Element elements[100]; }Menus; int main() { Menus menus[20]; Element element1; ...
  • 与所有“最有效率”的问题一样,唯一的方法就是在实际情况下测量实际表现。 一般来说,从连续内存位置的项目中可以获得很大的性能提升,因为对于任何一个接一个地处理项目的算法,这几乎总是最容易缓存的布局。 总体而言,连续数组使用更少的空间,因为您不需要额外的空间来存储额外的数据(如树节点)。 虽然在需要增长时将尺寸加倍是一种常见方法,但它可能会占用地址空间。 一些STL实现将结构像向量一样增长1.5倍,而不是2倍,以避免某些病态情况。 在短期内,这会导致更多的分配,但会导致更少的内存碎片。 如果你使用realloc ...
  • 首先,使用正确的强制转换,因为你似乎知道如何指向一个数组: struct pdirectory (*test)[N] = (struct pdirectory (*)[N])0x00001000; 其次, test[i]将以数组大小为单位执行指针运算。 如果数组的大小为N ,那么数组访问将等同于: *(struct pdirectory(*)[N])((unsigned char*)test + i * sizeof(struct pdirectory) * N) 正如你所看到的,上面并没有给test指 ...
  • 当你返回它时你不应该取消引用数组1 ,它实际上是与函数返回类型不兼容的类型,只是 return array; 另外,在读取值之前检查array != NULL malloc()之后的array != NULL ,并且你真的不需要typedef它会让你的代码有点混乱。 如果您编译的代码我怀疑,那么您的编译器命令中没有启用警告,启用它们以便您可以防止出现此类问题。 (1) *array相当于array[0] 。 You should not dereference the array when you ret ...
  • 如果将来的答案不正确,需要更改,我将隐藏在可用格式中的数组。 $desired = array(); $desired['info'][0]['player'] = 'Messi'; $desired['info'][0]['week']['id'] = 252; $desired['info'][0]['week']['videos'][2]['id'] = 2929847; $desired['info'][0]['week']['videos'][2]['link'] = 'dribbling ...
  • 改成: state states[] = { {'A', states+3, states+4}, //You probably meant states, since state is a type {'B', states, states+5}, {'C', states+4, states }, {'D', states+5, states+6}, {'E', states+1, states+7}, {'F', s ...
  • 我过去使用指针而不是数组做过这个。 我认为您的结构正在被复制用于P / Invoke调用: [DllImport("mathlib.dll")] static extern void TEST_REF(ValueRef* t, int n); 在调用方法之前,您需要固定数组。 fixed (ValueRef* pointer = t) { TEST_REF(pointer, n); } 编辑:根据注释,解决方案是将外部声明为 [DllImport("mathlib.dll")] static ext ...
  • 你需要a适当的结构数组,即用兼容的字段集初始化它: a = struct('ID', {}, 'pass', {}); b = struct('ID', 1, 'pass', 34); a(1) = b; You need a to be a proper structure array, i.e. initialise it with the compatible set of fields: a = struct('ID', {}, 'pass', {}); b = struct('ID', 1, ' ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。