惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
B
Blog RSS Feed
I
InfoQ
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
H
Help Net Security
L
LangChain Blog
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏

博客园 - 瑞雪年

开始使用 Xamarin.Forms.Platform.Avalonia Git仓库迁移命令 .NET Core也可以使用MongoDB了 ng2-timesheet, 一个timesheet.js的angular2复制版 Angular 2 + Electron 开发web和桌面应用 Xamarin.Forms.Platform.Perspex, Xamarin Forms 的 Perspex(号称下一代WPF) 实现 Visual Studio Xamarin编译Android项目出错的解决办法 NativeScript 也能开发桌面应用 (nativescript-dotnet-runtime) iOS集成丁香园DXY OAuth 登陆 swift代码示例 WinObjC?这是什么鬼? 如何禁用Marlin温度保护 React Native也正式发布了 微信企业号 用javascript写Android和iOS naitve应用,实在炫酷。 CoreCLR 在 Linux 下编译成功 Swift 对比学习 (二) Swift 对比学习 (一) 重量级Orchard模块发布 - 模块生成工具RaisingStudio.ModuleGenerator coding.net
Salesforce + AngularJS + Bootstrap
瑞雪年 · 2016-01-30 · via 博客园 - 瑞雪年

也可以分成三步:

1. 添加css和js引用:

    <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"></apex:stylesheet>
    <script src="https://code.angularjs.org/1.4.9/angular.min.js"></script>
    <script src="{!$Resource.forcetk4ng}"></script>   

2. 添加html代码:

        <div ng-app="ngapp">
            <div ng-controller="positionCtl">
                <button ng-click="getPositions()" class='btn btn-primary'>Retrieve Data</button>
                <table class='table table-bordered table-hover  table-striped '>
                    <thead>
                        <tr>
                            <td>Id</td>
                            <td>Name</td>
                            <td>IsAllow</td>                            
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="record in position.records">
                            <td>{{record.Id}}</td>
                            <td>{{record.Name}}</td>
                            <td>{{record.IsAllow__c}}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

3. 添加js代码,使用forcetk4ng获取数据:

        angular.module('ngapp', ['forcetk4ng'])
            .controller('positionCtl', function($scope, force){
                force.setAccessToken('{!$Api.Session_ID}');
                $scope.position = {};    
                $scope.getPositions = function(){
                    var soql = "select Id, Name, IsAllow__c from PositionTest__c";
                    force.query(soql)
                    .then(
                        function(records){
                            $scope.position.records = records;
                        },
                        function(event){
                            console.log(event);
                        }
                    );
                };        
                $scope.getPositions();
            });

示例: https://c.ap1.visual.force.com/apex/TestApexPage (此地址为个人测试地址)

注:可以给apex:page添加一些属性,去掉Salesforce样式和菜单,就和普通html页面一样了。

<apex:page standardStylesheets="false" showHeader="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">