简体   繁体   English

在使用Angular ui-bootstrap时出现错误:[$ compile:nonassign]

[英]Getting Error: [$compile:nonassign] while using Angular ui-bootstrap

I am getting the following error while navigating one page to another page using ui-bootstrap of Angular.js. 使用Angular.js的ui-bootstrap将一页导航到另一页时出现以下错误。

Error: [$compile:nonassign] http://errors.angularjs.org/1.4.6/$compile/nonassign?p0=%24state.current.name%20%3D%3D'principal.myplanManagement.myPlan'&p1=uibTab
    at Error (native)
    at http://oditek.in/Gofasto/js/angularjs.js:6:416
    at q (http://oditek.in/Gofasto/js/angularjs.js:74:45)
    at l (http://oditek.in/Gofasto/js/angularjs.js:74:120)
    at Object.<anonymous> (http://oditek.in/Gofasto/js/angularjs.js:116:15)
    at n.$digest (http://oditek.in/Gofasto/js/angularjs.js:130:71)
    at n.$apply (http://oditek.in/Gofasto/js/angularjs.js:133:236)
    at HTMLAnchorElement.<anonymous> (http://oditek.in/Gofasto/js/angularjs.js:253:36)
    at HTMLAnchorElement.m.event.dispatch (https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js:4:8549)
    at HTMLAnchorElement.r.handle (https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.

I am explaining my code below. 我在下面解释我的代码。

<div>
 <uib-tabset>
 <uib-tab ui-sref="principal.myplanManagement.myTimeTable" active="$state.current.name =='principal.myplanManagement.myTimeTable'">
      <uib-tab-heading>Add MyTimeTable</uib-tab-heading>
    </uib-tab>
    <uib-tab ui-sref="principal.myplanManagement.myPlan" active="$state.current.name =='principal.myplanManagement.myPlan'">
      <uib-tab-heading>Add MyPlan</uib-tab-heading>
    </uib-tab>
    <uib-tab ui-sref="principal.myplanManagement.myWDS" active="$state.current.name=='principal.myplanManagement.myWDS'">
      <uib-tab-heading>Add MyWDS</uib-tab-heading>
    </uib-tab>
    </uib-tabset>
  <div ui-view></div>
</div>

When i am moving to Add MyPlan page this type of error i am getting in console.Please help me to resolve this error. 当我移至“添加MyPlan”页面时,我在控制台中遇到此类错误。请帮助我解决此错误。

You can't put an expression in the active attribute as it's non-assignable. 您不能将表达式放在active属性中,因为它是不可分配的。

You'd need a new variable / object to define which tabs are active. 您需要一个新的变量/对象来定义哪些选项卡处于活动状态。

$scope.tab3 = $state.current.name === 'principal.myplanManagement.myWDS';

active="tab3"

or 要么

$scope.tabs = {
    1: ($state.current.name === 'principal.myplanManagement.myTimeTable'),
    2: ($state.current.name === 'principal.myplanManagement.myPlan'),
    3: ($state.current.name === 'principal.myplanManagement.myWDS')
};

active="tabs[1]"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM