$ location.path(“/”);($location.path(“/”); not working properly)
当我尝试使用$ location.path()时,url会发生变化但是我传入的内容.path会被添加到我当前的url中。 我希望当我执行我的addShow()时,我想去index.html这是我的主页。 能否请你帮忙。 网址改变如下: http:// localhost:8080 / add ,当我执行我的addShow函数时,它更改为: http:// localhost:8080 / add#/我希望它更改为转到我的主页。
angular.module('app').controller("MainController",['$location', function($location) { var vm = this; vm.title = 'TV Show'; vm.searchInput = ''; vm.shows = [{ title: 'Game of Thrones', year: 2011, favorite: true }, { title: 'Walking Dead', year: 2010, favorite: false }, { title: 'Firefly', year: 2002, favorite: true }, { title: 'Banshee', year: 2013, favorite: true }, { title: 'Greys Anatomy', year: 2005, favorite: false }]; vm.orders = [{ id: 1, title: 'Year Ascending', key: 'year', reverse: false }, { id: 2, title: 'Year Descending', key: 'year', reverse: true }, { id: 3, title: 'Title Ascending', key: 'title', reverse: false }, { id: 4, title: 'Title Descending', key: 'title', reverse: true }]; vm.order = vm.orders[0]; vm.new = {}; vm.addShow = function() { vm.shows.push(vm.new); console.log(vm.shows); vm.new = {}; $location.path("/"); }; }]);
我的配置功能如下:
(function() { "use strict"; angular .module("app") .config(function($routeProvider, $locationProvider) { //$locationProvider.html5Mode(true); $routeProvider .when('/', { templateUrl: 'list.html', controller: 'MainController', controllerAs: 'main', }) .when('/add', { templateUrl: 'add.html', controller: 'MainController', controllerAs: 'main', }) ; }); })();
When I am trying to use $location.path(), the url changes but whatever I have passed in .path is appened to my current url. I want that when I execute my addShow(), I want to go to index.html which is my home page. Could you please help. The url changes like this: http://localhost:8080/add and when I execute my addShow function it changes to: http://localhost:8080/add#/ I want it to change to go to my home page.
angular.module('app').controller("MainController",['$location', function($location) { var vm = this; vm.title = 'TV Show'; vm.searchInput = ''; vm.shows = [{ title: 'Game of Thrones', year: 2011, favorite: true }, { title: 'Walking Dead', year: 2010, favorite: false }, { title: 'Firefly', year: 2002, favorite: true }, { title: 'Banshee', year: 2013, favorite: true }, { title: 'Greys Anatomy', year: 2005, favorite: false }]; vm.orders = [{ id: 1, title: 'Year Ascending', key: 'year', reverse: false }, { id: 2, title: 'Year Descending', key: 'year', reverse: true }, { id: 3, title: 'Title Ascending', key: 'title', reverse: false }, { id: 4, title: 'Title Descending', key: 'title', reverse: true }]; vm.order = vm.orders[0]; vm.new = {}; vm.addShow = function() { vm.shows.push(vm.new); console.log(vm.shows); vm.new = {}; $location.path("/"); }; }]);
my config function is as below:
(function() { "use strict"; angular .module("app") .config(function($routeProvider, $locationProvider) { //$locationProvider.html5Mode(true); $routeProvider .when('/', { templateUrl: 'list.html', controller: 'MainController', controllerAs: 'main', }) .when('/add', { templateUrl: 'add.html', controller: 'MainController', controllerAs: 'main', }) ; }); })();
原文:https://stackoverflow.com/questions/34012071
最满意答案
要从第15行读取,请修改您的查询以使用表名作为FROM
[Sheet1$A15:ZZ]
-var query = string.Format("select [Col1],[Col2],[Col3] from [{0}${1}]", "Sheet1","A15:ZZ");
A15表示标题行。
确保在连接字符串中设置了
"HDR=YES"
。To read from 15th row, modify your query to use table name as FROM
[Sheet1$A15:ZZ]
-var query = string.Format("select [Col1],[Col2],[Col3] from [{0}${1}]", "Sheet1","A15:ZZ");
A15 represents header row.
Make sure that you have set
"HDR=YES"
in your connection string.
相关问答
更多-
如果你在Excel中工作,你将在第二行继续点击删除,并观察下面的行向上移动,替换之前被删除行占用的单元格。 要在自动化中复制该行为: for (int i = 2; i <= rows; i++) { ((Range)ws.Rows[2]).Delete(XlDeleteShiftDirection.xlShiftUp); } 请注意,您也可以预先构建一个范围,并在没有循环的情况下删除它,这将更快: var range = (Range)ws.get_Range( ws.Cells[1,2 ...
-
从C#读取Excel文件(Reading Excel files from C#)[2022-07-28]
var fileName = string.Format("{0}\\fileNameHere", Directory.GetCurrentDirectory()); var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName); var adapter = new OleDbDataAdapter("SE ... -
C# - 如何从excel获取标题到datagridview?(C# - How to get the header from excel into datagridview?)[2023-01-25]
foreach (DataRow row in dtexcel.Rows) { for (int i = 0; i < dtexcel.Columns.Count;i++ ) MessageBox.Show(row[i].ToString()); // row[i] is what you want. } 此代码可以帮助您检查表中的所有记录。 foreach (DataRow row in dtexcel.Rows) { for (int i = 0; i < dt ... -
好的,你需要实现两件事情: 获取所需的工作表对象 获得所需的单元格,即B31从中读取数据 下面是代码片段,按名称获取工作表对象,按地址获取单元对象: Private Function GetWorksheet(ByRef document As SpreadsheetDocument, ByVal worksheetName As String) As Worksheet Dim sheets As IEnumerable(Of Sheet) = document.WorkbookPart.Work ...
-
从C#读取Excel文件(Reading an Excel File From C#)[2022-10-27]
我认为你的连接字符串格式错误,并且“无法找到可安装的ISAM”通常表明了这一点。 试试这个,它来自我拥有的一段操作代码: Excel 2007 string connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=No;IMEX=1\";", fullPath); Excel 2003 string connect ... -
我相信你的工作表名为_xlnm.Print_Area 。 尝试更改此行 var cmd = new OleDbCommand("SELECT * FROM [+"+sheet+"+]", conn); 至 var cmd = new OleDbCommand("SELECT * FROM ["+sheet+"]", conn); I believe your sheet is named _xlnm.Print_Area. Try changing this line var cmd = new Ole ...
-
假设您在Excel工作表中有固定的垃圾代码行,您可以像这样执行查询。 "SELECT * From [Sheet1$A5:C]" 这里假设您的标题位于第5行,C是数据结束的列。 这会正确加载列的标题名称。 添加上述查询所用的Excel快照。 Assuming you have fixed lines of junk code in your Excel Sheet, you could execute the query like this. "SELECT * From [Sheet1$A5:C]" ...
-
要从第15行读取,请修改您的查询以使用表名作为FROM [Sheet1$A15:ZZ] - var query = string.Format("select [Col1],[Col2],[Col3] from [{0}${1}]", "Sheet1","A15:ZZ"); A15表示标题行。 确保在连接字符串中设置了"HDR=YES" 。 To read from 15th row, modify your query to use table name as FROM [Sheet1$A15:ZZ]- ...
-
您可以依赖Rows / Columns属性,然后遍历所有包含的范围( Cells )。 示例代码: Range range1 = worksheet.Rows[1]; //For all columns in row 1 //Range range1 = worksheet.Columns[1]; //for all rows in column 1 foreach (Range r in range1.Cells) //range1.Cells represents all the columns/ro ...
-
用c#读取excel文件(Read excel file with c#)[2022-07-05]
您可以使用互操作,但这需要在运行该工具的计算机上安装Excel。 您必须引用Office或Excel,然后使用这些用法。 using Microsoft.Office.Core; using Excel = Microsoft.Office.Interop.Excel; 然后你可以读写它。 Excel.Application xlsApp = new Excel.Application(); Excel._Workbook wrk = xlsApp.Workbooks.O ...