如何在#之前摆脱不需要的字符串? (角)

时间:2015-08-20 15:37:21

标签: angularjs angular-ui-router

每当我访问url angular app仍然被hashtag污染。在角度初始化之后,有没有办法从url中删除 someRandomString

在浏览器中输入网址:url.dev/someRandomString

之后,角度将重定向(无需重新加载页面)我:url.dev/someRandomString#/理想它应该是url.dev/#/

我正在使用ui-router和angular。 html5模式已禁用。

1 个答案:

答案 0 :(得分:0)

是的,你可以。

只需将otherwise()设置为$urlRouterProvider模块的uiRouter提供程序的app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) { // Your custom routes $stateProvider .state('home', { url: '/', templateUrl: 'views/home.html' }); // Redirect to 'url.dev/#/' if no route matched $urlRouterProvider.otherwise('/'); } ]); 方法的参数(您已经使用过):

Dictionary<string, string> search = new Dictionary<string, string>();
            search.Add("ID", "ID");
            search.Add("ClientID", "ClientID");
            search.Add("ClientCode", "ClientCode");
            search.Add("BatchRef", "BatchRef");
            search.Add("CaseRef", "CaseRef");
            search.Add("AccountNo", "AccountNo");
             search.Add("MeterName", "MeterName");
            search.Add("MeterAddress", "MeterAdd");
            search.Add("MeterPostcode", "MeterPostcode");
            search.Add("AgentID", "AgentID");
            search.Add("CompletedDate", "CompletedDate");
            search.Add("SubmittedDate", "SubmittedDate");

            Systems.PopulateDataGrid(search, dgvSearch, SQLHelper.FillDataTable(sql, CommandType.Text, searchParameters));

private void dgvSearch_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            ListSortDirection direction;

            if (dgvSearch.Columns[e.ColumnIndex].HeaderText == "Agent")
            {
                if (dgvSearch.SortOrder == System.Windows.Forms.SortOrder.Ascending)
                    direction = ListSortDirection.Descending;
                else
                    direction = ListSortDirection.Ascending;

                dgvSearch.Sort(dgvSearch.Columns[e.ColumnIndex], direction);
            }
        }