无法使用angularjs stateParams发送非premitive参数

时间:2017-01-18 14:10:35

标签: javascript html angularjs

我有这个angular-js模板:

<md-content layout="row" layout-align="center center">

    <div layout="column" flex="50">
        <div>search results</div>
        <md-card flex="60" ng-repeat="voice in $ctrl.voices" ng-click="$ctrl.editVoice($index)">
            <md-card-title>
                <md-card-title-text>

...

我有这个angular-js代码:

app.component('voiceFormComponent', {
        templateUrl: 'partials/voice-form.html',
        controller:  ['$state', '$stateParams', '$http',
            function ($state, $stateParams, $http) {

                var self = this;
                console.log("in voice prompt component");

                var isVoiceUndefined = $stateParams.voice === undefined;

当模板发送onClick(1)并且“voices”数组中有3个元素时。

为什么我总是得到$stateParams.voice === undefined

1 个答案:

答案 0 :(得分:0)

你必须在州配置中定义所有参数,然后你可以使用ie $ state.go('state',{param:anyObject})