无法从Typescript类中的angular Directive加载模板(404)(Failed to load template ( 404 ) from angular Directive in Typescript class)
以下是我在typescript类中编写的angular Directive代码。 当我在浏览器中运行指令时。 我得到错误
无法加载模板:../ Template /inputcontrol.html(HTTP状态:404未找到) - 错误:$ compile:tpload错误加载模板
我正在使用asp.net mvc
如何设置角度的路径或templateUrl?
<input-control a="shan"></input-control>
虽然相对路径很好。
class InputControl implements ng.IDirective { restrict = "E"; scope = { a: "=a" }; templateUrl = "../Templates/inputcontrol.html"; controller = ["$scope", ($scope: any) => { console.log("this this controller", $scope.a); }]; controllerAs = "inputcontroller"; constructor(private $location: ng.ILocationService) { } link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl: any) => { console.log(this.$location); }; static factory(): ng.IDirectiveFactory { const directive = ($location: ng.ILocationService) => new InputControl($location); directive.$inject = ["$location"]; return directive; } } angular.module("SheetApp").directive("inputControl", InputControl.factory());
Following is my code for angular Directive written in typescript class. When i run the directive in browser. I get error as
Failed to load template: ../Templates/inputcontrol.html (HTTP status: 404 Not Found) - Error: $compile:tpload Error Loading Template
Im using asp.net mvc
How to set the path or templateUrl in angular ?
<input-control a="shan"></input-control>
Although the relative path is fine.
class InputControl implements ng.IDirective { restrict = "E"; scope = { a: "=a" }; templateUrl = "../Templates/inputcontrol.html"; controller = ["$scope", ($scope: any) => { console.log("this this controller", $scope.a); }]; controllerAs = "inputcontroller"; constructor(private $location: ng.ILocationService) { } link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl: any) => { console.log(this.$location); }; static factory(): ng.IDirectiveFactory { const directive = ($location: ng.ILocationService) => new InputControl($location); directive.$inject = ["$location"]; return directive; } } angular.module("SheetApp").directive("inputControl", InputControl.factory());
原文:https://stackoverflow.com/questions/34254901
最满意答案
使用
try .. except .. else
:for i in range(3, 0, -1): try: f() except IOError: if i == 1: raise print('retry') else: break
你不应该一般地捕捉到所有的错误。 只要让他们冒泡到适当的处理程序。
Use
try .. except .. else
:for i in range(3, 0, -1): try: f() except IOError: if i == 1: raise print('retry') else: break
You should not generically catch all errors. Just let them bubble up to the appropriate handler.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
尝试 - 除了循环内(try-except inside a loop)[2023-07-28]
使用try .. except .. else : for i in range(3, 0, -1): try: f() except IOError: if i == 1: raise print('retry') else: break 你不应该一般地捕捉到所有的错误。 只要让他们冒泡到适当的处理程序。 Use try .. except .. else: for i in range(3, 0, -1): try: f() ex ... -
性能: 在try / catch结构放置的地方绝对没有性能差异。 在内部,它们被实现为在调用该方法时创建的结构中的代码范围表。 当该方法正在执行时,try / catch结构完全不在图片之外,除非发生了一个抛出,然后将该错误的位置与该表进行比较。 这是一个参考: http : //www.javaworld.com/javaworld/jw-01-1997/jw-01-hood.html 该表描述了中途。 All right, after Jeffrey L Whitledge said that ther ...
-
在While循环中尝试捕捉(Try-Catch inside While Loop)[2023-12-02]
一旦捕获InputMismatchException,只需添加input.next() 。 catch (InputMismatchException e) { //if an exception appears prints message below System.err.println("Please enter a number! " + e.getMessage()); input.next(); // clear scanner wrong input continue; ... -
循环内的Wordpress循环(Wordpress loop inside loop)[2023-07-02]
我是这样做的。 在主要查询之前,我对特色帖子做了特殊查询。 $args2 = array( 'post_type' => 'post', 'posts_per_page' => 1, 'category_name' => 'TheCategoryName-Slug', 'ignore_sticky_posts' => 1 ); $my_query2 = new WP_Query($args2); $post_ids = array(); / ... -
如果我理解正确,您希望在迭代data期间分别在数据结构A_floated和B_floated收集“好”(浮动)行。 如果是这样,请尝试将以前的数据结构放在循环外部,并在将它们放入列表之前检查值是否可以转换为浮点数。 否则,值A可以转换而值B不可转换,这将导致A_floated和B_floated不同长度。 总结一下,请尝试以下代码: A_floated = [] B_floated = [] for i in range(len(data)): A = data[i]["column_A"] ...
-
正如这里写的: 命令不同步; 你现在不能运行这个命令 您不能同时进行两个查询,因为默认情况下mysqli使用无缓冲的查询(对于mysqli准备语句;与vanilla mysql_query相反)。 您可以将第一个获取到数组中并循环遍历,或者告诉mysqli缓冲查询(使用$stmt->store_result() )。 (由@Rasclatt回答) As written here: Commands out of sync; you can't run this command now You can't h ...
-
尝试和除了循环内(Putting a Try and Except inside a Loop)[2021-12-13]
你的except块不应该引发异常,下面是你可以做int的一个例子,你可以根据你的程序要求进行修改 count = 0 while count < 5: try: guess=int(input("Take a guess ")) except ValueError: print("You must enter a whole number") print("Please take another guess, making sure that it is a whole numb ... -
最新的解决方案可能类似于: while True: try: for i in data_names: #do something except Exception, e: #log or otherwise handle exception else: break The neatest solution would probably resemble: while True: try: ...