AngularJS で処理したいタグの周りを verbatim ~ endverbatim タグで囲むことで Django が {{ }} を処理するのを防ぎます。
<body ng-app="TestApp"> <div ng-controller="TestController as tc"> {% verbatim %} <p>{{ tc.message }}</p> {% endverbatim %} </div>
<body ng-app="TestApp"> <div ng-controller="TestController as tc"> {% verbatim %} <p>{{ tc.message }}</p> {% endverbatim %} </div>
<input is="core-input" id="input_records" required type="text" min="1" pattern="/^[\s]*[0-9]+[\s]*(,[\s]*[0-9]+[\s]*)*$/">
<input type="date" required id="input_date" name="date" value="{{ date }}">
Polymer({ date: new Date().toISOString().substr(0, 10), ...
Polymer({ date: new Date(), ready: function() { this.$.input_date.valueAsDate = this.date; }
<paper-input-decorator label="" error="入力必須" isInvalid="{{!$.input_name.validity.valid}}"> <input is="core-input" id="input_name" required type="text" value="{{ name }}"> </paper-input-decorator> <paper-button on-click="{{ post_data }}"></paper-button> <core-ajax id="post" url="/someurl" method="post" handleAs="json" on-core-response="{{ response }}" on-core-error="{{ error }}"> </core-ajax>
post_data: function() { if(!this.$.input_name.validity.valid){ alert("名前を入力してください"); } else { var data = { 'name': this.name, }; this.$.post.body = "data=" + JSON.stringify(data); this.$.post.go(); } }, response: function (event, response) { }, error: function(event, response) { }
class ActivityInfoListApi(View): def post(self, request, *args, **kwargs): data = request.POST.get("data", None) if data is None or len(data) == 0: return HttpResponseBadRequest() obj = json.loads(data) try: name = obj["name"] # 型チェック if (not isinstance(name, str) and not isinstance(name, unicode)): return HttpResponseBadRequest() # 受け取った値で何か処理… return HttpResponse("json形式文字列…") except KeyError: logging.error("Missing Parameter") return HttpResponseBadRequest()
<link rel="import" href="/bower_components/polymer/polymer.html"> <link rel="import" href="/bower_components/paper-button/paper-button.html"> <link rel="import" href="/bower_components/paper-dialog/paper-action-dialog.html"> <link rel="import" href="/bower_components/core-style/core-style.html"> <core-style id="my-dialog-style"> html /deep/ { width: 16px; height: 16px; } html /deep/ paper-action-dialog::shadow #scroller { width: 360px; height: 360px; } </core-style> <core-style ref="my-dialog-style"></core-style> <polymer-element name="my-paper-action-dialog" attributes="toggle"> <template> <style> :host { position: absolute; width: 100%; height: 100%; } </style> <paper-action-dialog id="dialog"> <div> ... </div> <paper-button dismissive>CANCEL</paper-button> <paper-button affirmative>OK</paper-button> </paper-action-dialog> </template> <script> Polymer({ toggle: function () { this.$.dialog.toggle(); } }); </script> </polymer-element>
Chart.defaults.Radar.pointLabelFontSize = 16; // 少し大きく(デフォルトは 10) Chart.defaults.Radar.pointLabelFontColor = 0x00FFFFFF; // 赤