February 2019
Beginner to intermediate
180 pages
4h 4m
English
To bind to window.location.pathname, we add a scope using [@bs.scope]. This defines the scope for [@bs.val]. For example, if you want to bind to the pathname property of window.location, you can specify the scope as [@bs.scope ("window", "location")]:
[@bs.val] [@bs.scope ("window", "location")] external pathname: string = "";
Or, we could include the scope in the string using only [@bs.val]:
[@bs.val] external pathname: string = "window.location.pathname";
Read now
Unlock full access