$ 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
2024-04-22 20:04

满意答案

要从第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中的所有行,除了c#中的头文件(How to delete all rows from excel except header in c#)

如果你在Excel中工作,你将在第二行继续点击删除,并观察下面的行向上移动,替换之前被删除行占用的单元格。 要在自动化中复制该行为: for (int i = 2; i <= rows; i++) { ((Range)ws.Rows[2]).Delete(XlDeleteShiftDirection.xlShiftUp); } 请注意,您也可以预先构建一个范围,并在没有循环的情况下删除它,这将更快: var range = (Range)ws.get_Range( ws.Cell...

从C#读取Excel文件(Reading Excel files from C#)

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 OleDbDataAdapte...

C# - 如何从excel获取标题到datagridview?(C# - How to get the header from excel into datagridview?)

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...

如何使用openXML C#将文件excel行和表格特定的读取到数据表中(How to read file excel row and sheet specific using openXML C# into data table)

好的,你需要实现两件事情: 获取所需的工作表对象 获得所需的单元格,即B31从中读取数据 下面是代码片段,按名称获取工作表对象,按地址获取单元对象: Private Function GetWorksheet(ByRef document As SpreadsheetDocument, ByVal worksheetName As String) As Worksheet Dim sheets As IEnumerable(Of Sheet) = document.WorkbookPart...

从C#读取Excel文件(Reading an Excel File From C#)

我认为你的连接字符串格式错误,并且“无法找到可安装的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 co...

在c#中读取excel(.xlsx)文件(reading excel (.xlsx) file in c#)

我相信你的工作表名为_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 = ne...

C#读取excel文件,其中标题不是第一行(C# reading excel file where the header is not the first row)

假设您在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#读取Excel文件(Reading an Excel file with C# with misplaced header row)

要从第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...

逐行读取excel文件,逐个单元格C#(Read excel file row by row, cell by cell C#)

您可以依赖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 colum...

用c#读取excel文件(Read excel file with c#)

您可以使用互操作,但这需要在运行该工具的计算机上安装Excel。 您必须引用Office或Excel,然后使用这些用法。 using Microsoft.Office.Core; using Excel = Microsoft.Office.Interop.Excel; 然后你可以读写它。 Excel.Application xlsApp = new Excel.Application(); Excel._Workbook wrk = xlsApp.Workbo...

相关文章

更多

Working on Free Software

This was written in December, 1999 Lots of programm ...

nginx配置中location的优先级

nginx配置中location的优先级:(location =) > (location 完整路径 ...

启动Solr服务报错:Path must not end with / character

今天在第一次对Solr的UI Console进行Add Core操作的时候,用了默认选项,提交后页面无 ...

Eclipse中Hadoop的DFS Location无法显示DFS下的文件 解决方法

问题如上图所示,前提是首先要将Hadoop正确安装,在命令行中可以运行例子程序,然后在eclipse中 ...

Hadoop格式化失败原因 Format aborted in path

user6@das0 Hadoop-0.20.203.0]$ bin/hadoop namenode ...

微软职位内部推荐-Senior SDE

微软近期Open的职位: Title: Sr. Software Development Engine ...

DataDir and DirectoryFactory in SolrConfig

Specifying a Location for Index Data with thedataDi ...

Solr_stopword相关注意事项

So in Solr, normally we’re used to stopwords just k ...

最新问答

更多

python的访问器方法有哪些

使用方法: class A(object): def foo(self,x): #类实例方法 print "executing foo(%s,%s)"%(self,x) @classmethod def class_foo(cls,x): #类方法 print "executing class_foo(%s,%s)"%(cls,x) @staticmethod def static_foo(x): #静态方法 print "executing static_foo(%s)"%x调用方法: a =

使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)

我认为你必须将两个TableGetway传递给UserTable构造。 你必须改变Module.php看看: public function getServiceConfig() { return array( 'factories' => array( 'User\Model\UserTable' => function($sm) { $userTableGateway = $sm->get('UserTable

透明度错误IE11(Transparency bug IE11)

这是一个渲染错误,由使用透明度触发,使用bootstrap用于在聚焦控件周围放置蓝色光环的box-shadow属性。 可以通过添加以下类覆盖来解决它。 .form-control:hover { -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,255,1); -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,255,1); box-shadow: 0px 0px 4px 0px rgba(0,0,255,1)

linux的基本操作命令。。。

ls 显示目录 mkdir 建立目录 cd 进入目录

响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)

将z-index设置为.main-nav这将解决您的重叠问题 .main-nav { position:relative; z-index:9; } set z-index to .main-nav This will fix your overlaping issue .main-nav { position:relative; z-index:9; }

在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)

这是因为模式规范"a"打开一个文件以便追加,文件指针在末尾。 如果您尝试从此处读取,则由于文件指针位于EOF,因此没有数据。 您应该打开"r+"进行阅读和写作。 如果在写入之前读取整个文件,则在写入更多数据时,文件指针将正确定位以追加。 如果这还不够,请探索ftell()和fseek()函数。 That is because the mode spec "a" opens a file for appending, with the file pointer at the end. If you

NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)

支持空中接口的数据速率是一回事。 在消除协议开销,等待eeprom写入以及所有需要时间的其他内容之后,您看到的数据速率是完全不同的故事。 长话短说,从标签读取或进行对等传输时的实际数据速率峰值约为2.5千字节/秒。 取决于具体的标签或对等技术,它可能比这慢很多。 The supported data-rates of the air-interface are one thing. The data-rate that you see after removing protocol overhe

元素上的盒子阴影行为(box-shadow behaviour on elements)

它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂

Laravel检查是否存在记录(Laravel Checking If a Record Exists)

这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found

设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)

$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640