角度ui-router动态锚

时间:2018-05-14 22:46:59

标签: angularjs angular-ui-router

这里的情况。 我在视图中有动态生成的锚(例如id是id="{{replace(indice[1])}}"),当我在视图中时,一切都很好。如果我尝试从另一个视图到达该锚点,则会出现问题。我得到了正确的网址costituzione/#/altre-costituzioni#la-costituzione-del-regno-unito,但页面没有滚动到锚点。 我用:

ui-sref="altrec({'#': '{{replace(indice[1])}}'})"

状态是:

 var altreState = {
        name: 'altrec',
        url: '/altre-costituzioni',
        templateUrl: 'costituzioni/altrec.html',
        controller: function($scope){
          $scope.indice =["Quando e perchè sono nate le Costituzioni",
                         "La Costituzione del Regno Unito",
                         "La Costituzione americana",
                         "La Costituzione francese",
                         "La legge fondamentale della Germania",
                         "La costituzione spagnola"

                          ];
         $scope.bandiera=["img/why.png",
                          "img/bandiera_inghilterra.png",
                          "img/bandiera_americana.png",
                          "img/bandiera_francese.png",
                          "img/bandiera_germania.png",
                          "img/bandiera_spagna.png"

                           ]
          $scope.replace= function(newStr){
            newStr = newStr.replace(/\s/g, "-").toLowerCase();
            return newStr;
          }
        }
      }

由于

0 个答案:

没有答案