TypeError:undefined不是$ location中的函数。$$ state angular js

时间:2015-02-09 16:46:42

标签: javascript angularjs angular-ui-router state

我正在尝试将数据添加到$ location。$$状态对象,目前正在执行console.log($ location。$$ state)给我

Object
key: "Core/Views/dash:1"
parameters: Array[0]
view: "Core/Views/dash"

我想将以下数据添加到状态对象

breadcrumb : Array[4]

我尝试了以下代码,但却给了我错误

$location.$$state.push({breadcrumb:['home','page1','page2,'page3']});

错误

TypeError: undefined is not a function

任何想法如何将属性添加到现有状态对象?

1 个答案:

答案 0 :(得分:0)

在代码中添加'(单引号)将解决问题。

$location.$$state.push({breadcrumb:['home','page1','page2','page3']});