如何从Angular 2中导入的组件访问数据?

时间:2016-09-17 03:49:35

标签: javascript html css angularjs angular

我的navbar.component.ts (click)=toggle(!isOn); ison会将true的值更改为falsewelcome.component.ts

我有另一个组件navbar.component.ts。我将Navbar导入Navbar.isOn。当我尝试记录undefined时,它会显示Navbar。当我记录function Navbar() { this.selectedcity = 'Location'; this.isOn = false; this.isDisabled = false; } 时,它会给出

isOn

如何访问<div id="leftcol"> <div class="leftpadding"> <div class="logo_container"> <h1 class="logo"> <a href="/index.php" title=""> <span> <img src="your_logo_url" alt="logo" /> </span> </a> </h1> </div> <div class="moduletable"> </div> </div> 的值。我想要做的是在用户点击按钮时隐藏身体溢出。

Angular 2 Version 2.0.0-beta.15

1 个答案:

答案 0 :(得分:0)

注意:其他方式也有,但需要知道组合关系。

使用(截至目前)注射器,如下所示,

        choice=menu()

        while choice!='5':
                num1=int(input("enter first number: "))
                num2=int(input("enter the second number: "))


                if choice=='1':


                        total= addTwoNumber(num1,num2)
                        print("sum of two numbers is: ",total)
                        conti=contin()
                        return

                elif choice=='2':


                        sub=minTwoNumber(num1,num2)
                        print("num1-num2",sub)
                        conti=contin()
                        return
                elif choice=='3':

                        quo,remain=qrTwoNumber(num1,num2)
                        print(quo)
                        print(remain)
                        conti=contin()
                        return
                else:
                        print("Wrong Option.Kindly choose between 1 to 4 : ")
                        choice=menu()






def menu():

        print("Welcome to the menu.Kindly choose from below: ")
        print("1.To add two numbers: ")
        print("2.To subtract two numbers: ")
        print("3.For quotient and remainder :")
        print("4.Exit Program")
        opt=input("Enter number between 1-4")
        if opt=='4':
                print('Exiting program')

        return opt
def addTwoNumber(n1,n2):

    sum=n1+n2
    return sum
def minTwoNumber(a1,a2):

    minus=a1-a2
    return minus
def qrTwoNumber(q1,q2):

    quotient=q1//q2
    remainder=q1%q2
    return quotient,remainder
def contin():

        con=input("Do you want to continue (Y/N):")
        if con=='y' or con=='Y':
                choice=menu()
        else:        
                print("Exiting program")
                sys.exit()


main()

<强> http://plnkr.co/edit/xYO7zA?p=preview