因此,当前我正在路由到页面以从策略中获取文档列表。我还将引入所有策略,因此您可以浏览选择表单,并使用传递的策略编号将其重新路由到该表单。有没有一种方法可以选择使用新网址进行浏览的选项。
<mat-form-field name="selectPolicy">
<mat-select placeholder="Change Policy">
<mat-option *ngFor="let policy of policies" [routerLink]="['../', policy.policyNbr]">{{policy.policyTypeDesc}}
#{{policy.policyNbr}}
</mat-option>
</mat-select>
</mat-form-field>
截至目前,这会更改我的网址,但更改后确实会提交到新页面。
答案 0 :(得分:2)
from collections import defaultdict
record_keys = ['name', 'rating', 'price', 'cuisine']
def load(file):
with open(file) as file:
data = file.read()
restaurants = []
# chop up input on each blank line (2 newlines in a row)
for record in data.split("\n\n"):
fields = record.split("\n")
# build a dictionary by zipping together the fixed set
# of field names and the values from this particular record
restaurant = dict(zip(record_keys, fields))
# split chops apart the type cuisine on comma, then _.strip()
# removes any leading/trailing whitespace on each type of cuisine
restaurant['cuisine'] = [_.strip() for _ in restaurant['cuisine'].split(",")]
restaurants.append(restaurant)
return restaurants
def build_index(database, key, value):
index = defaultdict(set)
for record in database:
for v in record.get(key, []):
# defaultdict will create a set if one is not present or add to it if one does
index[v].add(record[value])
return index
restaurant_db = load('/var/tmp/r')
print(restaurant_db)
by_type = build_index(restaurant_db, 'cuisine', 'name')
print(by_type)
//assuming you have a route set up to take the value as a param
navigateTo(value){
console.log(value);
this.router.navigate(['../',value]);
}
答案 1 :(得分:0)
在该类中,如果您有一个,可以在ngOnInit之后