我有和昨天一樣的問題:我需要通過AngularJS在HTML頁面中使用來自URL的參數。我的錯誤是什麼?通過HTML中的變量使用URL參數AngularJS
我需要顯示和使用參數,如:
https://url.com/index.html?user
我需要該「用戶」,但現在不工作,沒有錯誤,現在,沒有什麼,其實,只是一個只有@的空h1。 :(
<div class="container" id="body-container" ng-controller="myController as myApp">
<h1 id="header-username">@{{myApp.user}}</h1>
</div>
我應該做點別的?
(function() {
var app = angular.module('MyApp', ['ngRoute']);
app.controller('myController', function ($scope, $location) {
this.user = $location.search();
});
})();