【问题标题】:How to get current state in Angularjs [duplicate]如何在Angularjs中获取当前状态[重复]
【发布时间】:2017-12-29 14:45:55
【问题描述】:

我在我的 .html 文件中使用这样的方法,但它不起作用。

 <p>State is {{state.current.name}}</p>

在 controller.js 中我可以得到它。 但我想在 html 文件中获取它。 任何人都可以在这方面帮助我。

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    在控制器中将状态分配给变量

    $scope.state = $state;
    

    现在您可以在 HTML 中访问它。

    <p>State is {{state.current.name}}</p>
    

    确保将$state 注入控制器。

    【讨论】:

    猜你喜欢
    • 2016-12-02
    • 1970-01-01
    • 2014-07-17
    • 2014-09-22
    • 2015-03-25
    • 2018-07-23
    • 2015-03-26
    相关资源
    最近更新 更多