0
私はテンプレート内のボタンがあります。
self.SearchForPersonByName = function (searchTerm, onlyPractitioners)
{
var searchResource = $resource('../angularSupport/controllers/common/PersonNameSearch/');
var params = new Object();
params.searchTerm = searchTerm;
params.onlyPractitioners = onlyPractitioners;
// saw this on StackOverflow but this doesn't stop it from refreshing the page
$scope.$on('$locationChangeStart', function (event)
{
event.preventDefault();
});
var dataResult = searchResource.query(params);
dataResult.$promise.then(function (data)
{
// this never executes; page refreshes instead
self.data = data; // update model data
console.log('Data: ' + data); // check data format
UpdateAutoComplete(); // will show a dropdown list of names to pick from,
// given the search text and result, using self.data
});
console.log('path: ' + $location.path());
}
パスログ::私が持っているコントローラで
<button value="Test Service (Search)" ng-click="$ctrl.SearchForPersonByName('winn', false)">
Test Service (Search)</button>
path: /ha/1338378
完全なパスは、次のとおりです。
/WebContent/Pages/MyPage.aspx#!/ha/1338378
私は、サーバーからデータを取得し、名前のリストを更新するためにそれを使用する代わりに、ナビゲーションの
/WebContent/Pages/MyPage.aspx
:$リソースがクエリを実行または取得した後、その結果はとナビゲーションがあります。私は同じURLを維持したい。
トレースを実行すると、コールバックが呼び出されることなくウィンドウアンロードイベントが発生します。 AngularはXHRリクエストからの応答を得ていますが、これはサーバーの問題ではないため、整形式であると思われます。