我使用$ routeParams从URI中提取属性并将本地变量设置为它们.
当我使用typescripts键入来设置$ routeParams的类型时,我无法访问$ routeParams.
如何访问$ routeParams中的属性?
class Controller{
constructor($routeParams: ng.route.IRouteParamsService, private $location: ng.ILocationService)
this.propetry1 = this.getProperty1($routeParams.property1);
}
property1: string;
getProperty1(input: string):string{
return (input || "Not present");
}
Run Code Online (Sandbox Code Playgroud)
}
ng.route.IRouteParamsService代码是:
interface IRouteParamsService {
[key: string]: any;
}
Run Code Online (Sandbox Code Playgroud)
这有一个错误:属性'property1在ng.route.IRouteParamsService的类型上不存在'
如果我将$ routeParams的类型更改为:any,则它会正确设置property1.如何在仍然访问$ routeParams中的属性的同时保持Typescript的严格输入?
我正在尝试使用bootstrap 4的新卡组件创建一个由许多卡填充的页面.
我想创建一个搜索栏,搜索时会筛选出标题与搜索查询不匹配的卡片.
这是我想到的东西.Plunker
我希望卡片能够得到类似的东西display: none,或者opacity:0它们是否匹配.
我目前正在尝试编写onChange搜索栏的功能.我会发布,如果我能弄明白的话.
我也试过使用内置代码段功能.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js"></script>
<link href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-sm-4">
<input type="search" placeholder="Search......" name="search" class="searchbox-input" onkeyup="buttonUp();" required>
</div>
<div class="col-sm-4">
</div>
<div class="col-sm-4">
</div>
</div>
<div class="card-columns">
<div class="card">
<div class="card-block">
<h4 class="card-title">Card title that wraps to a new line</h4>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a …Run Code Online (Sandbox Code Playgroud)javascript jquery twitter-bootstrap twitter-bootstrap-4 bootstrap-4