Is there any way to allow my directives in WordPress post? Like:
app.directive('postMeta', function() {
return {
restrict: 'E',
template: 'post meta template:'
};});
In my post, I write
<post-meta></post-meta>
It does nothing too. Some easy syntax like
{{ 3 + 2 }}
Do nothing too, just echo {{ 3 + 2 }}. All these tags in template works well.
P.S. template like this:
https://github.com/1fixdotio/angularjs-demo-theme
Script.js:
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
...
$routeProvider.when('/:slug', {
templateUrl: myLocalized.partials + 'content.html',
controller: 'Content'
})
...
app.controller('Content', ['$scope', '$routeParams', '$http', '$compile', function($scope, $routeParams, $http, $compile) {
$http.get('wp-json/posts/?filter[name]=' + $routeParams.slug).success(function(res){
$scope.post = res[0];
$compile($scope.post.content)($scope);
})
...
app.directive('postMeta', function() {
return {
restrict: 'E',
replace: true,
template: '<div>template of postMeta directive</div>',
controller: function($attrs, $scope) {
$scope.test = 'test in controller';
console.log('attrs = ' + $attrs.description);
},
link: function(scope, element) {
console.log('inside link ');
}
};
});
Inside wp post:
Uncategory blog 2 {{ 2 + 3 }}
<post-meta description="My description in post">{{test}}</post-meta>
Outside:
http://postimg.org/image/mfeytefhb/