Tutorial by Examples: control

if (i < 2) { System.out.println("i is less than 2"); } else if (i > 2) { System.out.println("i is more than 2"); } else { System.out.println("i is not less than 2, and not more than 2"); } The if block will only run when i is 1 or less. The else if...
In its most simple form, an if condition can be used like this: var i = 0; if (i < 1) { console.log("i is smaller than 1"); } The condition i < 1 is evaluated, and if it evaluates to true the block that follows is executed. If it evaluates to false, the block is skipped....
A controller is a basic structure used in Angular to preserve scope and handle certain actions within a page. Each controller is coupled with an HTML view. Below is a basic boilerplate for an Angular app: <!DOCTYPE html> <html lang="en" ng-app='MyFirstApp'> <head...
A newline can be included in a single-string or double-quoted string. Note that backslash-newline does not result in a newline, the line break is ignored. newline1=' ' newline2=" " newline3=$'\n' empty=\ echo "Line${newline1}break" echo "Line${newline2}break" ...
angular .module('app') .controller('SampleController', SampleController) SampleController.$inject = ['$log', '$scope']; function SampleController($log, $scope){ $log.debug('*****SampleController******'); /* Your code below */ } Note: The .$inject will make sure your...
There are a couple different ways to protect your controller creation from minification. The first is called inline array annotation. It looks like the following: var app = angular.module('app'); app.controller('sampleController', ['$scope', '$http', function(a, b){ //logic here }]); The...
UIAlertView and UIActionSheet are Deprecated in iOS 8 and Later. So Apple introduced a new controller for AlertView and ActionSheet called UIAlertController , changing the preferredStyle, you can switch between AlertView and ActionSheet. There is no delegate method for it because all button events a...
All looping constructs allow the use of break and continue statements. They affect the immediately surrounding (innermost) loop. Basic Loop Control break terminates the loop: for x in 0..5 { if x > 2 { break; } println!("{}", x); } Output 0 1 2 continue finishes...
To previous view controller To pop back to the previous page you can do this: Swift navigationController?.popViewControllerAnimated(true) Objective-C [self.navigationController popViewControllerAnimated:YES]; To root view controller To pop to the root of the navigation stack, you can do...
In your storyboard select the ViewController that you want to embed into a Navigation Controller. Then navigate to Editor > Embed In > Navigation Controller And that will create your navigation controller
The flow of execution of a Ruby block may be controlled with the break, next, and redo statements. break The break statement will exit the block immediately. Any remaining instructions in the block will be skipped, and the iteration will end: actions = %w(run jump swim exit macarena) index = 0 ...
To generate a controller (for example Posts), navigate to your project directory from a command line or terminal, and run: $ rails generate controller Posts You can shorten this code by replacing generate with g, for example: $ rails g controller Posts If you open up the newly generated app/...
Common mobile-optimized sites use the <meta name="viewport"> tag like this: <meta name="viewport" content="width=device-width, initial-scale=1"> The viewport element gives the browser instructions on how to control the page's dimensions and scaling based...
You should implement SFSafariViewControllerDelegate so that your class is notified when the user hits the Done button on the SafariViewController and you can dismiss it as well. First declare your class to implement the protocol. class MyClass: SFSafariViewControllerDelegate { } Implement th...
Don't forget to import the necessary framework first. import SafariServices //Objective-C @import SafariServices; Instantiate a SafariViewController instance. let safariVC = SFSafariViewController(URL: URL(string: "your_url")!) //Objective-C @import SafariServices; NSURL *URL = [...
In Angular $scope is the glue between the Controller and the View that helps with all of our data binding needs. Controller As is another way of binding controller and view and is mostly recommended to use. Basically these are the two controller constructs in Angular (i.e $scope and Controller As). ...
tl;dr : Create a base class that defines two user objects (say user and another_user). Create your other models and define three Client instances. self.client : Representing user logged in browser self.another_client : Representing another_user 's client self.unlogged_client : Representing unlo...
Blade provides convenient syntax for common PHP control structures. Each of the control structures begins with @[structure] and ends with @[endstructure]. Notice that within the tags, we are just typing normal HTML and including variables with the Blade syntax. Conditionals 'If' statements @if...
In Objective-C, method swizzling is the process of changing the implementation of an existing selector. This is possible due to the way Selectors are mapped on a dispatch table, or a table of pointers to functions or methods. Pure Swift methods are not dynamically dispatched by the Objective-C run...
Controller class names are pluralized. The reason is the controller controls multiple instances of object instance. For Example: OrdersController would be the controller for an orders table. Rails will then look for the class definition in a file called orders_controller.rb in the /app/controllers ...

Page 1 of 13