Angular 7从组件导航到另一个

时间:2019-02-22 09:00:02

标签: angular angular7

enter image description here 如何从新合同组件导航到客户详细信息组件?

我尝试关注new-contract组件,但它一直导航到404。

pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

3 个答案:

答案 0 :(得分:1)

尝试一下-

this.router.navigateByUrl(/customer/customer-details);

答案 1 :(得分:0)

使用router在页面之间导航。将组件导入路由模块中 并这样做

this.router.navigate('customer/customer-details')

答案 2 :(得分:0)

由于要使用url字符串导航,因此必须使用Router.navigateByUrl函数。

@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@WebMvcTest(CaDetailController.class)
public class CaDetailControllerTest {

    private static ObjectMapper objectMapper = null;

    private List<CaDetail> caDetails;

    @Autowired
    private MockMvc controller;

    @MockBean
    CaDetailRepository repository;

    @BeforeClass
    public static void beforeClass() {
        objectMapper = new ObjectMapper();

    }

    @Before
    public void before() {
        caDetails = new ArrayList<CaDetail>();
    }

    @After
    public void after() {
        caDetails = new ArrayList<CaDetail>();
    }

    @AfterClass
    public static void afterClass() {
        objectMapper = null;
    }

    @Test
    public void getCorporateActions() throws Exception {
        MvcResult result = controller.perform(MockMvcRequestBuilders.get("/api/ca").accept(MediaType.APPLICATION_JSON)).andReturn();
        caDetails = objectMapper.readValue(result.getResponse().getContentAsByteArray(), new TypeReference<List<CaDetail>>() {
        });
        System.out.println(">>>>>>>>>>>>>>> caDetails : " + caDetails);
        assertNotNull(caDetails);
        assertTrue(caDetails.size() > 0);
    }