ラベル angular の投稿を表示しています。 すべての投稿を表示
ラベル angular の投稿を表示しています。 すべての投稿を表示

2017/05/07

exec-maven-plugin java angular

pomファイルに下記を追加:
<build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.example.DemoApplication</mainClass>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <configuration>
                    <workingDirectory>${project.basedir}/src/main/angular</workingDirectory>
                    <executable>ng.cmd</executable>
                    <arguments>
                        <argument>build</argument>
                        <argument>--watch</argument>
                        <argument>--output-path=${project.basedir}/src/main/resources/static</argument>
                    </arguments>
                </configuration>
            </plugin>
        </plugins>
    </build>


IDEのdebug configurationのmaven goadsに
exec:exec
を記載してangular buildを実行する
exec:javaでspringを実行する

 うまくいきました!!
次はangularのhot swapping ね!!

2014/07/03

angularJS scope.$apply

JavaScript is Turn Based
私たちが記述するJavaScriptのコードは一度に全て実行されるのではなく、ターンベースで実行される。各ターンは始めから終わりまで中断せずに走り、ターンが走っている間はブラウザ上では何も起きない。他のどのJavaScriptのコードも走っていない時は、Webページインタフェースは完全に固まる。だから不十分なJavaScriptコードはウェブページの動きを止めてしまう。

変更した時に通知でき、ページを更新できる。==>EmberJS や KnockoutJS

どのJavaScriptコードのターンが終わった時でも、値が変化したことを確認する。=>AngularJS
この戦略を動かすためには、データが変更された可能性がある時点を知る必要がある。そしてこれが $scope.$apply が動き始める場所だ。
  $scope.$apply(function () { $scope.msgs.push(JSON.parse(msg.data)); });

==>このapplyの中の物は、後で実行される感じだね。。。

2014/06/18

AngularJs 考え方

★In Angular applications, the view is the Document Object Model (DOM), the controllers
are JavaScript classes, and the model data is stored in object properties.

★Dependency injection lets us follow a development style in which, instead of creating dependencies,
our classes just ask for what they need.This follows a design pattern called the Law of Demeter, also known as the principle of
least knowledge.
==>scope,location
最小知識の原則ーー>簡潔に言うと「直接の友達とだけ話すこと」と要約できる。友達の友達であるクラスと関係をもってはいけない

★Angular comes with many HTML extension directives that help you define the view for your app


★<script src-"">
Using Google’s CDN is recommended. Google’s servers are fast, and the script is cacheable
across applications. That is, if your user has multiple apps that use Angular, she’ll
have to download only it once. Also, if the user has visited other sites that use the Google
CDN link for Angular, she won’t need to download it again when visiting your site.


With modules, and the dependency injection we get from them, we can write our controller
much more simply, like this:
==>
function ShoppingController($scope, Items) {
$scope.items = Items.query();
}
==ー>The preceding code assumes that we’ve defined Items as a service
Services are singleton (single-instance) objects that carry out the tasks necessary to
support your application’s functionality. Angular comes with many services like $loca
tion, for interacting with the browser’s location, $route, for switching views based on
location (URL) changes, and $http, for communicating with servers.
You can, and should, create your own services to do all of the tasks unique to your
application. Services can be shared across any controllers that need them. As such,
they’re a good mechanism to use when you need to communicate across controllers and
share state. Angular’s bundled services start with a $, so while you can name them
anything you like, its a good idea to avoid starting them with $ to avoid naming collisions.

===>Springみたいね。。。
・factory(name,$getFunction)、A non-configurable service with complex creation logic. You specify a function that, when
called, returns the service instance.
・provider(name,object)、A configurable service with complex creation logic. If you pass an Object, it should have a
function named $get that returns an instance of the service.
・service(name,constructor())=->


例:
// Create a module to support our shopping views
var shoppingModule = angular.module('ShoppingModule', []);
// Set up the service factory to create our Items interface
shoppingModlue.factory('Items',function(){
    var itmes={};
    items.query= function(){
        return[
        {name:'l',sex:'1'},
        {name:'m',sex:'1'},
        {name:'n',sex:'1'}
        ];
    };
    return items;
});

function ShoppingController($scope, Items) {...}
==>When Angular creates the ShoppingController, it will pass in $scope and the new
Items service that we’ve just defined. This is done by parameter name matching. That
is, Angular looks at the function signature for our ShoppingController class, and
notices that it is asking for an Items object. Since we’ve defined Items as a service, it
knows where to get it
To get this to work with our template, we need to tell the ng-app directive the name of
our module, like the following:
<html ng-app='ShoppingModule'>

・In most applications, it will work well enough to create a single module for all the code
you create and put all of your dependencies in it.

・みたいな、自分でfilterも定義できる
var homeModule = angular.module('HomeModule',[]);
homeModule.filter('titleCase',fuction(){
    var myownFilter = function(input){
    }
    return myownFileter;
}
);


・Though AJAX apps are technically single-page apps (in the sense that they only load an
HTML page on the first request, and then just update areas within the DOM thereafter),
we usually have multiple sub-page views that we show or hide from the user, as appropriate.
==>AJAXはそんな事をやっている?なるほど~

・$routeProvider
var someModule = angular.module('someModule', [...module dependencies...])
someModule.config(function($routeProvider) {
$routeProvider.
when('url', {controller:aController, templateUrl:'/path/to/tempate'}).
when(...other mappings for your app...).

otherwise(...what to do if nothing else matches...);
)};


・talk to the server
==>そんなに重いことはない。。
function ShoppingController($scope, $http) {
    $http.get('/products').success(function(data, status, headers, config) {
        $scope.items = data;
    });
}


・自分のderectiveを作る。
var appModule = anguler.module('appModule',[...]);
appModule.directive('directiveName',directiveFunction);

ng-option room.name for room in rooms
ng-model
ng-change
ng-submit
==>

・ng-repeat="msg in msgs | limitTo:-4"

★A module is a collection of services, directives, controllers, filters, and configuration information.
・var myModule=angular.module('myModule',[])
[]コレクションだね。。
・myModule.value('appName','MyCoolApp');

Then you can create an injector and load your modules like this:
var injector = angular.injector(['ng', 'myModule'])

2014/06/12

AngularJs 入門

★load説明:
<!doctype html>
<html lang="en" ng-app>
<head>
  <meta charset="utf-8">
  <title>My HTML File</title>
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
  <link rel="stylesheet" href="css/app.css">
  <script src="bower_components/angular/angular.js"></script>
</head>
<body>

  <p>Nothing here {{'yet' + '!'}}</p>

</body>
</html>
=ー>
・ブラウザがHTMLがロードする後、angular.jsをロードする
・ng-appーー>angularJSの勢力範囲を説明したので、angular.jsの動きを制御する
・{{}}はコアの機能である。angularは中の物を解析して、DOMに入れて、TWOーWAY bindingはそれより実現される。

・Most applications have a main method that instantiates and wires together the different parts of the application.
Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped.

疑問点:
・imperative指令?
・injector?
    ーー>すでにどこであるので、必要であれば君に与える。君は自分で作る必要がない。
    その事をする物はinjectorである!例 
    function?PhoneListCtrl($scope,?$http)?{
        http.get(....).success(function(data))....
    }
   
    ==>function定義のところで、引数はhttpである==>これがほしいよ。はい。。どうぞの感じはinject!!?

===>抽象すぎの記述があるので「moduleなど」、まぁ。。。ゆっくり勉強しましょう。。