Skip to content

Get "TypeError: Cannot read property 'match' of undefined" when using ng-attr-ui-sref #2090

@sharpmachine

Description

@sharpmachine

Hi there,

I only want to add the ui-sref attribute IF {{item.state}} is defined. That's what ng-attr is for. But when I use it on on ui-sref, like so ng-attr-ui-sref={{item.state}}, it works great in the DOM but in the console I get TypeError: Cannot read property 'match' of undefined. It only throws this error when I use ng-attr on ui-sref.

<div class="list-group">
  <a 
        ng-attr-ui-sref="{{item.state}}" 
        ng-repeat="item in dynamicPopover.items" 
        ng-attr-ng-click="item.click($event, object.id)" 
        class="list-group-item">
    <i class="fa fa-{{item.icon}}"></i>
    {{item.title}}
    <paper-ripple fit></paper-ripple>
  </a>
</div>

Full Error

TypeError: Cannot read property 'match' of undefined
    at parseStateRef (http://localhost:9000/bower_components/angular-ui-router/release/angular-ui-router.js:4015:22)
    at link (http://localhost:9000/bower_components/angular-ui-router/release/angular-ui-router.js:4100:17)
    at invokeLinkFn (http://localhost:9000/bower_components/angular/angular.js:8258:9)
    at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7768:11)
    at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7117:13)
    at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7120:13)
    at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7120:13)
    at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7763:24)
    at delayedNodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:8016:11)
    at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7117:13) <a ng-attr-ui-sref="{{stateName}}" class="card-header">

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions