Reputation: 33
If you can see here the code I made it in SAP WEB Ide then I moved to an apache server to test due to CORs problems. I only want that Log In button to call the alert, but it is not even working.
Here I posted the JSBIN to make it easier to understand: https://jsbin.com/cejicaqobe/edit?html,output
<Button text="Log In " width="100px" id="myButton" press="getLogin"/>
Upvotes: 1
Views: 1061
Reputation: 5216
In your JS Bin, the alert is not shown because you have not associated the view with the controller. The easiest way to do it is by passing a controllerName
to the view specification in the XML:
<mvc:View controllerName="sap.m.sample.NavContainer.C">
<!-- the view's contents -->
</mvc:View>
In the controller name, you have to pass the controller class name (you specified it in the Controller.extend
call). The instantiation of the controller is done for you by the framework.
I forked your bin and made it to work here: https://jsbin.com/gesezuhasa/1/edit?html,output.
Alternatively, you can pass a controller instance to the sap.ui.xmlview or sap.ui.view call. This means that you have to instantiate the controller first.
Upvotes: 1