Ir al contenido principal

Entradas

Mostrando entradas de julio, 2014

AngularJS ( Read parameters from URL)

Read parameters from URL Create a module  The important part is the function that receive the $locationProvider var app = angular.module('tagStatus', [], function ($locationProvider) {     $locationProvider.html5Mode(true); }); Create the function that is consider as Controller, in this case the name is  QueryCntl The  location.search() find the parameter, in this case  'page' function QueryCntl($scope, $location) {     $scope.target = $location.search()['page']; } In the HTML  Include the Module and Controller  Display the parameter  <div class="form_message" ng-app="tagStatus" ng-controller="QueryCntl as ctrl">                   {{target}} </div>

Android Architecture ( Synchronization and Scheduling )

Java Classes ReentrantLock A reentrant mutual exclusion lock that extends the built-in-monitor lock capabilities ReentrantReadWriteLock Improves performance when resources are read much more often than written Semaphore A non-negative integer that controls the access of multiple threads to a limited number of shared resources ConditionObject Block thread(s) until some condition(s) becomes true CountDownLatch Allows one or more threads to wait until a set of operations being performed in other threads complete Considerations ReentrantLock have lower overhead than ReentrantReadWriteLock ReentrantReadWriteLock may enable more concurrency on multi-core or multi-processor hardware ConditionObject & Semaphore have higher overhead than ReentrantLock & ReentrantReadWriteLock ConditionObject & Semaphore are more expressive & more flexible ConditionObject can be used to lock a thread to keep other threads out of a critical section ...

AngularJS (Dependencies / Services)

Dependency To use the functionality from one module inside another module. Create your first module Add your module inside your second module inside ['first_module'] If you did your first module in another file then import your file in your html <script src="product.js"/> Service Give functionality like: Fetching JSON data from a web service with $http Logging messages to JS console with $log Filtering an array with $filter All built-in Services start with dollar sign $ Service   $http  Make an async request to a server $http( { method: 'GET' , url: '/products.json' } ) ; Another way is $http.get( '/products.json' , {  apiKey: 'myApiKey'  } ) ; In both cases return a Promise object with .success() and .error() In this image appear how to declare the services in a Controller Then invoke our service How to manipulate the result Additional Options ...

AngularJS (Directives IV )

Ng-include This directive include another html file Custom Directives You can create your own directives as elements or attributes. *Tip: Use Elemente directives for UI widgets and Attribute Directives for mixin behaviors as a tooltip. Element Directive In this case this directive is created as an Element that include an html page Attribute Directive Use a Controller in a Directive You need to use: The keyword " controller " to specify the functionality  The keyword " controllerAs " to specify the alias Then use in the custom directive without ng-controller, because the controller functionality is defined in the new directive

AngularJS ( Form)

Form Turn off Html Validations Inside the tag <form> add the attribute novalidate Angular Validations Add the attribute  required  in each element Review validation To validate your form use in the ng-submit="reviewName .$valid " You can print if the form is valid as {{formName .$valid }} Style for validations When use the validations Angular pass through some styles So only you have to define your style Type of validations

AngularJS (Directives III )

Ng-model Binds the form element value to the property Example: In this case when type in the textarea the value is reflected in the blockquote Other examples: Ng-submit Call a function when the form is submitted * The method push add the element to the array named reviews.

AngularJS ( Directives II)

Create a Tab To create some tab use the tab and assign a value for each tab. Ng-click  Every time you do click in the link   a tab will be selected. Each time the tab is selected the value of {{tab}} is updated with the selected value of the tab Create a tab content panels Ng-init Allows to evaluate an expression in the current scope Ng-class Set a class according with one expression Create Tab using a Controller

AngularJS ( Filters)

Syntaxis {{ data* | filter:options*}} Currency {{product.price | currency}} Date {{ '1388123145' | date:'MM/dd/yyyy @ h:mma'}} To get the Date use Date.now() Uppercase &lowercase {{ 'text to change'  | uppercase}} LimitTo  {{ 'text to display'  | limitTo:8 }} orderBy <li ng-repeat="product in store.products  | orderBy: '-price' "> the minus sign '-' means descending

AngularJS ( Directives )

Ng-App Attach the Application Module to the Page Ng-Controller Attach a Controller function to the page Ng-Show Will show an element if true Ex: <button ng-show =" product.saleproduct.canPurchase "> Add to cart</button> product.saleproduct.canPurchase -  Property from the controller Ng-Hide Hide an element like a <div> Ex: <button  ng-hide =" product.saleproduct.soldOut "> </div> Arrays var  saleproducts = [   {      name: 'Porche' ,      price: 295 ,      desc: "My first car"    },   {      name: 'Audi' ,      price: 290 ,      desc: "My second car"    } ]; Length To get the size use length Ex:  product.images.length To display the array just indicate the element as usual    <h2> {{product.saleproduct [0] .price}} </h2> ...

AngularJS (Setup / Controller )

Download angular.min.js             https://angularjs.org/ Twitter Bootstrap (bootstrap.min.js)            http://getbootstrap.com/ Module Is where we write our code Implement Angular Create a  javascript file  to type your code <script type="text/javascript" src="resources/ myapp.js "> Create a Module In your  javascript file  create your first module Specify that is an Angular application Add in the tag <html>  the attribute ng-app=" module_name " This means that will run the module with name   module_name Tutorials http://campus.codeschool.com/courses/shaping-up-with-angular-js/intro https://egghead.io/ http://www.thinkster.io/ API http://kapeli.com/dash Expressions You can include in your code an expression  {{  4 + 6 }} {{ "Hello" + "message" }} Controller Where is defined...

CSS - Tricks

How establish a CSS according with the display size In the css file, add the tag @media Establish the dimensions  @media(min-width:992px)  @media(min-width:992px) and (max-width: 1200px)  @media (max-width: 991px)  Can also establish an attribute as screen This mean that in case of a print the style will not be considered only in the screens =P @media screen  and (max-width: 1000px)  @media only  screen  and (max-width: 1000px) 

C# Tricks

Datable Read a Column Select the row and then ask for the field. DataTable requestedTags; requestedTags.Rows[0]["status"] GridView Add a field To add a field beyond the result of your query use <asp:TemplateField>                <asp:TemplateField HeaderText="New On Board Week">                         <ItemTemplate>                             <asp:DropDownList ID="ddlChange" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlChange_SelectedIndexChanged">                                 <asp:ListItem>--Change in:--</asp:ListItem>                                 <asp:ListItem>...