2013-10-14 15 views
22

UI sref uygulayan bir bağlantı yerine ng-click kullanarak route.state öğesini nasıl değiştirebilirim?AngularJS ui yönlendiriciyi kullanarak ng tıklama ile yolu değiştir

<button ng-click="selectDir(file.fullPath)">set</button> 

$scope.selectDir = function(location) { 
    options.storageLocation = location; 
    $route.current = 'recorder.options'; 
} 

ile Ama çalışmıyor:

Bu denedim. Herhangi bir fikir?

+0

ui-sref bu yanıta bakın: örneğin İşte

$state.go('recorder.options') belgelerinde belirli işlevine bağlantı var http://stackoverflow.com/a/21105057/2539811 –

cevap

37

UI yönlendirici belgelerine bakın wiki.

En iyi çözüm $state.go() kullanmaktır. https://github.com/angular-ui/ui-router/wiki/Quick-Reference#stategoto--toparams--options

+1

tyvm i daha önce denenmiş . ama $ state enjekte unuttum .. bu yüzden işe yaramadı. Şimdi her şey güzel .. thx alot :) – marcel

+7

Tüm görünümlerinize '$ state 'enjekte etmenin bir yolu' angular.module (' myApp ') kullanmaktır. Run ([' $ rootScope ',' $ state ', fonksiyon) ($ rootScope, $ state) {$ rootScope. $ state = $ state;}]); '. – chipit24

+2

https://github.com/angular-ui/ui-router/wiki/Quick-Reference#note-about-using-state-within-a-template – chipit24