[Sublime Text] 配置JavaScript, PHP build system

首先配置 node 和 PHP 环境;
选择 Tools -> Build System -> New Build System 之后,

  • 创建 JavaScript.sublime-build 文件:

    {

    "cmd": ["node", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "working_dir": "${file_path}",
    "selector": "source.js",
    "shell": true,
    "encoding": "utf-8",
    "windows": {
     "cmd": ["node", "$file"]
    },
    "linux": {
     "cmd": ["killall node; node", "$file"]
    }
    

    }
    `

  • 创建 PHP.sublime-build 文件:

    `{

    "cmd": ["php", "$file"],
    "file_regex": "php$",
    "selector": "source.php"
    

    }

Ubuntu 16.04 配置 LAMP 环境(PHP7)

sudo apt-get update
`</pre>
## Step 1\. Install Apache2
<pre>`sudo apt-get install apache2
sudo ufw app list
//Sample output:
Available applications:
 Apache
 Apache Full
 Apache Secure
 OpenSSH
sudo ufw allow in "Apache Full" 
//Allow incoming traffic for this profile
`</pre>
## Step 2\. Install MySQL
<pre>`sudo apt-get install mysql-server
sudo mysql_secure_installation
`</pre>
## Step 3\. Install PHP
<pre>`sudo apt-get install php7
`</pre>
## Step 4\. Install PHP Modules
<pre>`apt-cache search php- | less
apt-cache show package_name
sudo apt-get install php7-*

遇到的问题:

  • 重新设置 Mysql user/pwd.(解决方法见链接2)

参考文章:
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04
MySQL ERROR 1698 (28000) 错误

[AngularJS] 重置表单class ng-dirty

在表单提交之后,如果仅仅是清空表单数据内容,相应 inputclass 并不会改变(依然是 ng-dirty 状态),我们需要移除这些红色的 required 提示。

 &lt;div ng-app="myApp" ng-controller="myCtrl as ctrl"&gt;
 &lt;form name="ctrl.myForm"&gt;
 &lt;div&gt;&lt;label for="email"&gt;Email&lt;/label&gt;
 &lt;input name="myInput" type="email" ng-model="ctrl.email" id="email" required&gt;&lt;/div&gt;
 &lt;div&gt;&lt;label for="password"&gt;Password&lt;/label&gt;
 &lt;input name="myPassword" type="password" minlength="8" ng-model="ctrl.password" id="password" required&gt;&lt;/div&gt;
 &lt;div&gt;
 &lt;button ng-click="ctrl.reset()" type="button"&gt;Reset&lt;/button&gt;
 &lt;/div&gt;
 &lt;/form&gt;
`</pre>
`JavaScript` 代码:
<pre>`
angular.module('myApp', [])
 .controller('myCtrl', myCtrl);
function myCtrl(){
 var vm = this;
 vm.reset = function(){
 vm.myForm.$setPristine();
 vm.myForm.$setUntouched();
 vm.email = vm.password = '';
 }
}

表单input区域必须放在 form

参考连接:Angular clear subform data and reset validation

AngularJS, Angular Material 与 Symfony 3 结合

首先需要在父级模版中引入 AngularJSAngular Material.

&lt;link rel="stylesheet" href="{{ asset('angular-material.css') }}"&gt;
&lt;link rel="stylesheet" href="https://fonts.googleapis.com/css?family=RobotoDraft:300,400,500,700,400italic"&gt;
&lt;script src="{{ asset('angular.js') }}"&gt;&lt;/script&gt;
&lt;script src="{{ asset('angular-aria.js') }}"&gt;&lt;/script&gt;
&lt;script src="{{ asset('angular-animate.js') }}"&gt;&lt;/script&gt;
&lt;script src="{{ asset('angular-material.js') }}"&gt;&lt;/script&gt;
`</pre>
在js文件中,写入:
<pre>`angular.module('myApp',['ngMaterial'])
 .config(function($interpolateProvider){
 $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
})
 .controller('myController', myController);
myController.$inject = ['$scope'];
function myController( $scope ) {
}`</pre>
最后,在twig模版中写scope变量时,需要写成:
<pre>`{[{ scopeVariable }]}

参考内容:

AltStyle によって変換されたページ (->オリジナル) /